Announcement Announcement Module
Collapse
No announcement yet.
Maven/Spring/Junit and the information-less stack trace.... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maven/Spring/Junit and the information-less stack trace....

    I am struggling to get proper information from my failed JUnit tests. Below is the setup of my BaseTestFactory class and I used Netbeans 6.8.

    Code:
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = {"file:src/main/webapp/WEB-INF/spring_config_testing.xml"})
    @TransactionConfiguration(transactionManager = "TransactionManager", defaultRollback = false)
    @Transactional
    public abstract class BaseTestFactory implements ApplicationContextAware {
    ...
    When I get the following failed test I find:
    1. Netbeans tells me about all the tests that passed, but doesn't even mention that one test failed (all the tests have green ticks against them, and the failed ones are just not there). I suspect that this is a Netbeans issue and an inability to parse the results of Maven run JUnit tests, but the question is: is there is a fix for it??
    2. When I check the maven error, I cannot get much information about what line caused the test to fail. I can see below that from the AssumptionViolationException that I "assumed" something wrong, but what and in which line did I do that? The stack trace provides no info about the failure but rather the resulting spring configuration error.

    Below is also a sample test. Maybe I am getting the test wrong?

    Any advice much appreciated.

    Pieter

    Code:
        @Test
        public void testProductionConfig() {
            ApplicationConfiguration config = applicationConfigurationFactory.getProductionConfig();
            Assert.assertNotNull(config.getDatabasepath());
            Assert.assertNotNull(config.getAdminpassword());
            Assert.assertNotNull(config.getApplicationname());
            Assert.assertNotNull(config.getApplicationversion());
            Assert.assertNotNull(config.getRootdbpassword());
            Assert.assertNotNull(config.getRootdbhost());
            Assert.assertNotNull(config.getRootdbport());
            Assert.assertNotNull(config.getRootdbusername());
        }
    Code:
    1948 [main] INFO org.springframework.test.context.transaction.TransactionalTestExecutionListener  - Committed transaction after test execution for test context [[TestContext@b70648 testClass = ApplicationConfigurationFactoryTest, locations = array<String>['file:src/main/webapp/WEB-INF/spring_config_testing.xml'], testInstance = [email protected]49436, testMethod = testTestConfig@ApplicationConfigurationFactoryTest, testException = java.lang.AssertionError: ]].
    org.apache.maven.surefire.booter.SurefireExecutionException: org/junit/Assume$AssumptionViolatedException; nested exception is java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException
    java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException
    	at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:281)
    	at org.springframework.test.context.junit4.SpringMethodRoadie$2.run(SpringMethodRoadie.java:207)
    	at org.springframework.test.context.junit4.SpringMethodRoadie.runBeforesThenTestThenAfters(SpringMethodRoadie.java:254)
    	at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:234)
    	at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:204)
    	at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:146)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:151)
    	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61)
    	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:54)
    	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
    	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
    	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:52)
    	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
    	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
    	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
    	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
    	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
    Caused by: java.lang.ClassNotFoundException: org.junit.Assume$AssumptionViolatedException
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    	... 22 more

  • #2
    My bad. I went back to the JUnit4.4 (I was using JUnit 4.7). THis seems to be a known problem with backward compatibility.

    Comment

    Working...
    X