JUnit testcase passes with eclipse but fails with maven build

后端 未结 2 618
甜味超标
甜味超标 2021-01-20 22:38

I wrote a JUnit test case for JPA using spring. The testcase passes in eclips. But if I execute the same testcase using maven (mvn test) it fails.

My test case is :

2条回答
  •  不知归路
    2021-01-20 22:54

    I have solved this problem. The problem was mainly because of the dependency

     
        javaee 
        javaee-api 
        5 
        provided 
    
    

    Actually this dependency was required for EJB so I placed this in my parent pom (and also in my testcases pom). Since my test case's pom had a parent depedency, by default it will be inherited. If you add this dependency then u must have a java EE container to run the program. Testcase does not require Java EE container.

    Remove this dependency if you have the one in your pom file.

    Have a look on Problem running unit tests from maven (JPA related) for more detail.

提交回复
热议问题