我正在尝试在 junit 5 的帮助下为一个类编写一些测试。我已经使用 Maven 导入了依赖项,但是当我尝试使用注释 @CsvFileSource(resources = "/testlist) 导入一个 csv 文件以用作测试用例时.csv") 我收到这个错误
org.junit.platform.commons.PreconditionViolationException: Classpath resource [/testlist.csv] does not exist
Run Code Online (Sandbox Code Playgroud)
这是我正在运行的代码
package com.faezeh.shayesteh;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
public class MultipleOperationParamTest {
@ParameterizedTest
@CsvFileSource(resources = "/testlist.csv")
void testMultipleOpWithCsvFileSrc(int operand, int data, int result){
MultiplyOperation multop = new MultiplyOperation(operand);
int actual = multop.operate(data);
Assertions.assertEquals(result,actual);
}
}
Run Code Online (Sandbox Code Playgroud)