Testing with SpringJUnit4ClassRunner

Testing with SpringJUnit4ClassRunner is breeze.

First add annotations:

@ContextConfiguration(locations = { "/appContext.xml" })
public class SimpleDaoTest{

Place resources on classpath:


Add dependencies:


Annotate test class:

@Autowired private SimpleDAO dao;

Ready to Test !

Tagged with: , ,
Posted in JUnit, Spring, Testing
One comment on “Testing with SpringJUnit4ClassRunner
  1. […] If using SpringJUnit4ClassRunner methods demarcated with @Transactional will not commit unless @Rollback(false) or […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: