Running jenkins gives "org.junit package does not exist"

Can someone help me with this error?

build-project: [echo] AntProject: /root/.jenkins/jobs/Ant/workspace/build.xml [javac] Compiling 2 source files to /root/.jenkins/jobs/Ant/workspace/bin [javac] /root/.jenkins/jobs/Ant/workspace/src/com/moi/test/junit/MaClasseTest.java:3: package org.junit does not exist [javac] import static org.junit.Assert.*; [javac] ^ [javac] /root/.jenkins/jobs/Ant/workspace/src/com/moi/test/junit/MaClasseTest.java:5: package org.junit does not exist [javac] import org.junit.Test; [javac] ^ [javac] /root/.jenkins/jobs/Ant/workspace/src/com/moi/test/junit/MaClasseTest.java:9: cannot find symbol [javac] symbol : class Test [javac] location: class com.moi.test.junit.MaClasseTest [javac] @Test [javac] ^ [javac] /root/.jenkins/jobs/Ant/workspace/src/com/moi/test/junit/MaClasseTest.java:12: cannot find symbol [javac] symbol : method assertTrue(boolean) [javac] location: class com.moi.test.junit.MaClasseTest [javac] assertTrue(MaClasse.additioner(2,2) == 4); [javac] ^ [javac] 4 errors BUILD FAILED /root/.jenkins/jobs/Ant/workspace/build.xml:35: Compile failed; see the compiler error output for details. 
+4
source share
4 answers

It seems you forgot to make junit library available in your class

+2
source

You need to provide a compilation path for the javac class, which includes junit.jar.

Check out the <classpath> inside the <javac> for one way to solve this problem.

0
source

My decision:

  • Download junit.jar
  • In the projet.properties file, find the line "javac.test.classpath = \" and add / your / path / to / junit -4.10.jar to the end
  • you can check locally to see if it works
  • click on github
  • based on jenkins and voila it works :)
0
source

I ran into this problem because I accidentally put the damaged Java JUnit test source file in the location src/main/java/... instead of the correct src/test/java/...

My IDE Eclipse did not complain about the lack of imports and was happy to run tests from this file while it was in src/main/java/... - while Jenkins would interrupt the construction and therefore testing.

Moving the problem file to the right place, src/test/java/... , solved my problem.

0
source

All Articles