I have a project that creates a bean library and is built upon spring boot. In the latest spring tools suite (eclipse), I have a set of junit test cases that stands up a spring boot server and tests those beans. All tests are passing. I heard about the EclEmma eclipse plugin so I installed it. I left the defaults and just ran 'Coverage As' > 'JUnit Test' just like I can successfully run 'Run As' > 'JUnit Test', but the coverage is failing with
IllegalStateException: Failed to load ApplicationContext
I checked the classpath and it matches the successful JUnit runas because it's the same run as configuration. Can anyone help me?
Related
My project is a webapplication, currently I have deployed it my local machine. I have some testcases written in Mockito, Junit.
When I run the Junit test on the whole project, by right clicking on project , all these test cases run successfully but when I pick up an individual test case and run it I get the below error and test case wont run.
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
I have all the required jars of mockito and junit.
I'm having a little problems running JUnit tests from Eclipse directly (using the "Run As JUnit test" on the JUnit test file I want to run) on a simple Spring Boot application.
I'm using Gradle as a build tool. Now, when running the test as a Gradle task it works just fine, but when running it as an Eclipse JUnit task it fails with the follwoing error
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.
My application.properties files does define a local MySQL database and that seems to work fine with gradle:
spring.datasource.url: jdbc:mysql://localhost:3306/test
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
My Application Class:
#SpringBootApplication
public class Application {
My Application test:
#RunWith(SpringJUnit4ClassRunner.class)
#SpringApplicationConfiguration(classes = Application.class)
#WebAppConfiguration
public class ApplicationTests {
Any ideas?
I am using the JUnit for code coverage in my project. For db i am using the dbunit as like mock DB. When i am running JUnit from Eclipse UI its getting passed, but its getting failed when run through maven.
Above set up is running fine in JDK 1.6.25 by using maven and its started failing when upgraded to 1.8.51. I had updated the maven compiler plugin, its doesn't work. I am used below versions, junit - 4.7 2.dbunit - 2.4.8 hsqldb - 2.0.0 maven - 2.2.1.
Issue:
-> All test cases which ran fine in JAVA 1.6, started failing on migrating to JDK 1.8.51.
-> Due this we faced build failure issue and also code coverage reduction.
Root Cause:
-> JUnit uses Java reflection to get the test methods from Test classes. In JAVA 1.6 test method order returned as same as declaration in source file.
-> But from JAVA 7 onwards the methods order returned the by JVM is not same as the source file, it will be returned randomly.
-> Since our test cases are dependent on each other, due to order change it started failing.
For Example below test cases are using the same data (Mock DB) for execution,
-> AddOperationTestCase()
-> EditOperationTestCase()
-> DeleteOperationTestCase()
If delete run first due JVM random order, for Add and Edit data won't be available it will fail.
Solution :
-> I had tried to find options in JUnit and Sure Fire plugin to maintain same order as like source file, but I could not find feasibility there.
-> I have identified the class which will returns the order of execution in JUnit library and override that accordingly to run it source file order.
-> As of now I had added this annotation wrapper to failed classes, now build is running successfully.
Link for Wrapper class:
https://somethingididnotknow.wordpress.com/2014/03/07/run-junit-tests-in-order/
I want in my multi-moduled project to have integration tests using JUnit and TestNG containers. Is it possible to do that without this error:
Multiple TestRunners found, only one allowed. Check your classpath
I get this error when I have together below dependencies for
arquillian-junit-container
arquillian-testng-container
please,
I wrote a test app in JavaFx 2.0 + EJB in the Netbeans IDE and I got a problem running this app outside netbeans.
I have a form using FXML and an action of this form runs a EJB method. I am using the Glassfish Server.
When I run this test app on netbeans it works perfectly, but when I run the app outside of Netbeans like jnlp or in the browser ... the app can't access the EJB methods. I couldn't see the error message in webstart or in the browser. So, I ask:
1) How can I see the error message in a web start or in the browser? (like javaws test-app.jnlp)
2) I guess the error occurs because of classpath issues. (I need gf-client.jar and javaee-api-6.0.jar in the classpath in order the app works). How can I assure these jars are in the classpath?
Sorry by my english.
Thanks,
Cleber.
to see errors from jnlp you need to enable Java Console:
Control Panel - Java Properties - Advanced - Java Console - Enable Console
for jnlp case all external libs should be stated in jnlp file. Usually NetBeans do it for you, but you can debug this case by reviewing Java Console output.