Junit parameterized tests using file input

后端 未结 3 1686
渐次进展
渐次进展 2021-01-06 05:10

I have a query about using parameterized tests for my unit testing of my APIs. Now instead of building an arraylist like

Arrays.asList(new Object[]{
   {1},         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-06 05:24

    @RunWith(JUnitParamsRunner.class)
    public class FileParamsTest {
    
        @Test
        @FileParameters("src/test/resources/test.csv")
        public void loadParamsFromFileWithIdentityMapper(int age, String name) {
            assertTrue(age > 0);
        }
    
    }
    

    JUnitParams has support for loading the data from a CSV file.

    CSV File will contain

    1,true
    2,false
    

提交回复
热议问题