所以我发现junit 5具有注释
@ParametrizedTest
@CsvFileSource(filenames)
Void testmethod(String column1,String column2)
因此该csv的每一行都将作为单独的测试用例。 就我而言,我需要根据csv中的所有数据创建一个大型测试。
Junit提供类似ArgumentAggregator的功能,它可以帮助创建从csv列到的对象
@ParametrizedTest
@CsvFileSource(filenames)
Void testMethod(@AggregateWith(PersonAggregator.class) Person person)
最后一个问题是如何将所有csv行压缩到一个测试中
@ParametrizedTest
@CsvFileSource(filenames)
Void testMethod(@AggregateWith(PersonAggregator.class) List<Person> person)
我可以手动读取csv文件并压缩聚合器中的所有行,但是我认为应该有一些内置的解决方案?