JUnit Test Editor and Spring

CodePro AnalytiX (Audit & Test), includes over 1000 audit rules and metrics, JUnit test generation & editing, code coverage, and duplicate code analysis

Moderators: gnebling, jwren, Eric Clayberg, Dan Rubel, Brian Wilkerson, dcarew

JUnit Test Editor and Spring

Postby ftr » Wed Sep 22, 2010 4:38 am

Hi,

In my JUnit 4 Tests I use Spring 3.0.x's custom Test Runner (org.springframework.test.context.junit4.SpringJUnit4ClassRunner) via @RunWith:

Code: Select all
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-test-context.xml" })
public abstract class MyTests implements ApplicationContextAware {

   @Autowired
    private MyDao dao;

    @Test
    public testSomething(){
         assertEquals("expected String", dao.getExpectedString());
    }
}


This automatically injects the suitable bean from the Spring context into my testcase. This works in Eclipse and when I run the tests in Maven. The CodePro Test Editor however marks all my tests as failed because of a NullPointerException when accessing "dao". I cannot find the complete stacktrace, only the tooltip which points me to a NullPointer in the line where I access "dao", but this indicates to me that the @RunWith annotation is ignored.

Is there a way to configure the Test Editor to be able to work with custom Test Runners?

Thanks,
Florian
ftr
 
Posts: 5
Joined: Mon Sep 20, 2010 6:35 am

Re: JUnit Test Editor and Spring

Postby jwren » Wed Sep 22, 2010 3:25 pm

The JUnit Test Editor does not currently work with third party libraries such as Spring.

To open a Java file with the default Eclipse Java Editor, context click (right click) on the file in the Project Explorer, and select Open With > Java Editor.
--
Jaime Wren
Software Engineer
Google Inc.
jwren
Moderator
 
Posts: 2
Joined: Mon Sep 20, 2010 7:23 am

Re: JUnit Test Editor and Spring

Postby ftr » Wed Sep 22, 2010 11:24 pm

The JUnit Test Editor does not currently work with third party libraries such as Spring.


Ok. Are you planning to change that in the foreseeable future?
ftr
 
Posts: 5
Joined: Mon Sep 20, 2010 6:35 am


Return to CodePro AnalytiX & PlusPak. EclipsePro Audit & Test

Who is online

Users browsing this forum: No registered users and 1 guest

cron