advice on integration testing my dao layer

123 Views Asked by At

I have a spring mvc application, and I am using jdbctemplate for my database Dao objects.

How should I go about integration testing?

Where should I put my integration testing files, is this layout correct:

/src/main/test/integration/...

or

/src/main/integration/...

How will this work, for my test cases, I should have a base class or some code in my setup that will run once before starting my testing where it loads the spring configuration/application context.

How should I do this?

1

There are 1 best solutions below

0
On

If You are using Maven, tests should go to src/test/java. If You're not, it seems like a reasonable place anyway. To set up spring context You should use @RunWith(SpringJUnit4ClassRunner.class) together with @ContextConfiguration, no initialization code necessary.