我有一个测试,我想传递三个参数:
- 字符串
- 枚举
- 字符串数组
示例:
@ParameterizedTest
@CsvSource({
"/path/to/first/file.xlsx, FIRST, {THIRD PARAMETER SHOULD BE ARRAY OF STRINGS}",
"/path/to/second/file.xlsx, SECOND, {THIRD PARAMETER SHOULD BE ARRAY OF STRINGS}"})
void uploadFile(String path, FileType type, String[] errors) {
HttpEntity httpEntity = prepareFileUploadEntity(path, type);
ResponseEntity<ArrayList> response = getRestTemplate(AppRole.USER).exchange(UPLOAD_URL, HttpMethod.POST, httpEntity, ArrayList.class);
assertNotNull(response);
assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
assertEquals(errors.length, response.getBody().size());
for (String error : errors) {
assertTrue(response.getBody().contains(error));
}
}
我该如何将第三个参数传递为一个字符串数组?因为现在我遇到了第三个参数无法解析的错误。org.junit.jupiter.api.extension.ParameterResolutionException: Error resolving parameter at index 2