简体   繁体   中英

Write a base Test Class with Junit4 in spring mvc

Im going to write test classes with spring mvc.I think writing base test class is good thing to do first.I have already written some service classes in service layer anyone can help me to write base test class in spring mvc with junit4.I need to test all test cases when building an application. Can you explain it with simple example ? Thanx

Try writing your test cases without a base class first, and then you will see the base class emerge. Don't assume you need one right away.

It is a good idea, you can put common functionality in there, eg:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext-test.xml")
@WebAppConfiguration
public abstract class Base {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM