Springboot(SpringMVC)で、Mybatisを使用してDBからデータを取得できるかどうかのテストをしようと思い、JUnitを勉強しています。
テストクラスは、src/test/javaの直下にパッケージを作成して書いています。
ネットで色々調べて書いてはみた(特にアノテーション部分)のですが、以下のエラーから抜け出す事が出来ません。
context.xmlは、src/main/resources/springmvc-configにあります。
ItemRepositoryはインターフェースです。
書き方が正しいかどうかも分からないのですが、まずはこのエラーから抜け出したいです。
字数制限がある様なので、エラーメッセージは画像で載せています。
ご教授宜しくお願いします。
@RunWith(SpringRunner.class) @SpringBootTest //@ContextConfiguration(locations="classpath:springmvc-config/context.xml") @ContextConfiguration @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) public class ItemRepositorySelectAllTest { @Inject ItemRepository itemRepository; @Test @DatabaseSetup("/dbunit/itemTest.xml") public void testSelectAll() throws Exception { int count = itemRepository.count(); assertEquals(count, 2); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。