我已经编写了这个测试
@Test
@UsingDataSet(locations = {"dataset.json"}, loadStrategy= LoadStrategyEnum.CLEAN_INSERT)
public void readAndupdateTemplate(){
..............
}
我的根项目具有以下结构
app
|
|_ _ src
|_ _ main
| |_ _ java
| | ......(my packages)
| |_ _ resources
|
|_ _ test
|_ _java
| .....(my test packages)
|_ _resources
上面编写的类的测试位于 app/src/test/java
中,而我的 dataset.json
位于 app/src/test/resource
当我尝试运行此测试时,出现此错误
java.lang.IllegalArgumentException: File specified in locations property are not present in classpath, or no files matching default name are found. Valid default locations are: /xx/xxxxxxxxx/xxxxxxxxxx/service/TemplateServiceTest.json or /xx/xxxxxxxxx/xxxxxxxxxx/service/TemplateServiceTest#readAndupdateTemplate.json
最佳答案
刚刚进行了相同的搜索,并找到了主 nosql site 上示例的链接。 如果您的测试位于 com.lordofthejars.nosqlunit.demo.mongodb 包中,则需要在测试资源目录 - com/lordofthejars/nosqlunit/demo/mongodb 中创建所有文件夹,并将 dataset.json 放在那里。 这是example
关于java - nosqlunit 注解@UsingDataSet位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37070943/