Skip to main content

JUnit issue with Eclipse and Maven

In this post I am trying to resolve one issue of JUnit with Eclipse and Maven. Sometimes while using JUnit with Eclipse and Maven we have to face certain issues. And one of them is whenever we try to run the independent test case it will run fine and will not give any type of error. But when we run to try to compile the whole project, the same test will not compile at all. This is an annoying issue if someone does not know about the functionality of how Eclipse works with JUnit and Maven.

Since there is such no exception seen in file, but project compilation fails due to same file it is very frustrated for developer to figure out the issue. I am facing this issue and found a solution by googling around many forums.
Problem: You have created a JUnit test case in the project and it is running fine, but fails to compile the whole project when try to build using Maven.
Solution: Check that the test case you have created exist in the src/test/java folder and not in src/main/java. Very funny isn't it. Actually Maven compiles the files under src/main/java to target/classes and src/test/java to target/test-classes.
So whenever you try to build the project it encounters the JUnit test class but it will not able to compile. So, put file in src/test/java folder and the project will run smoothly :)
Thanks for reading blog.

Comments

Popular posts from this blog

Getting height and width of image in Java

Yesterday I was working on something that requires manipulation of image for getting its properties. After searching over the internet I found a very intersting class on Java i.e ImageIO and BufferedImage class. These classes are good enough to manipulate images. there are many other claases also. But what I need i got it from these. I found many developers searching over internet for getting properties of image and there is no good small example for that. Thats why I thought why not creating a simple code to manipulate the image and help the developers. Here is the small code that helps to get the height and width of the image. Enjoy it!! import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class GetImage { public static void main(String[] args) { try { File f = new File("E:/Vinod/Docs/Pics/krishna_01.jpg"); BufferedImage image = ImageIO.read(f); int height = image.getHeight(); in...

First Time Deployment of war file to IBM Cloud

In this post, I will put a very basic deployment of Java war file on the IBM Cloud . Previously, IBM Cloud was known as IBM Bluemix . But in this post, I will prefer using the IBM Cloud and not the bluemix. I was facing problem while deploying the war file on the IBM Cloud for the first time. I am not a DevOps person who knows about the servers as well. But my job was to deploy the application on the IBM Cloud I need to do it. So, I tried googling around but have no idea about how to do it. There are some examples are given but they are not so basic to be understood by a developer who wants to deploy the application in Cloud. But I manage to do it. And I will explain all the steps that are needed to deploy the application to the Cloud. The application I am going to deploy is the Spring Boot application. Requirements 1. IBM Cloud account. 2. IBM Bluemix CLI 3. war file (spring-boot application) IBM Cloud  Setup After signing for IBM Cloud, go to the IBM Cloud Dashboard...

My JUnit Write Ups

I haven't written to my blog for a long time. There are times when you are busy and didn't get the time to work on the blogs. I am writing for Java Code Geeks for some time and busy with one of the projects that I was building for a client. Most of the blogs that I am writing was on JUnit. If you like this blogs do follow me on the Java Code Geeks at my author page . Also, if possible do upvote my links on DZone . I will be regularly writing on JUnit there. Hope you like those.