【发布时间】:2020-04-12 11:57:49
【问题描述】:
我正在尝试在 junit 5 的帮助下为一个类编写一些测试。我已经使用 Maven 导入了依赖项 但是当我尝试使用注释 @CsvFileSource(resources = "/testlist.csv") 导入 csv 文件以用作测试用例时 我收到此错误
org.junit.platform.commons.PreconditionViolationException: Classpath resource [/testlist.csv] does not exist
这是我正在运行的代码
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);
}
}
【问题讨论】: