Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 spring mvc 应用程序,我正在为我的数据库 Dao 对象使用 jdbctemplate。
我应该如何进行集成测试?
我应该把我的集成测试文件放在哪里,这个布局是否正确:
/src/main/test/integration/...
或者
/src/main/integration/...
这将如何工作,对于我的测试用例,我应该在我的设置中有一个基类或一些代码,这些代码将在开始我的测试之前运行一次,它会加载弹簧配置/应用程序上下文。
我该怎么做?
如果你使用 Maven,测试应该去 src/test/java。如果你不是,无论如何这似乎是一个合理的地方。设置spring上下文你应该使用@RunWith(SpringJUnit4ClassRunner.class)和@ContextConfiguration,不需要初始化代码。