java - JUnitParamsRunner with input file - string parameter issue -


i want move junit test parameters separate csv file. use junitparamsrunner that:

@runwith(junitparamsrunner.class) public class testclass { ... @test     @fileparameters("src/test/resources/input.csv")     public void testmethod(int assertresult, string inputmark) throws interruptedexception { .... 

my csv file that

2,"xxx" 2,"xxx" 2,"xxxx,xxx-1" 4,"xxxx xxxxx-xx" 

when run test parameter "xxxx,xxx-1" gives me java error because of wrong number of arguments (i think because of comma inside). how can pass string parameters special symbols in cvs file in scenario?

provide custom mapper parse csv data:

@runwith(junitparamsrunner.class) public class testclass {      @test     @fileparameters(value = "src/test/resources/input.csv", mapper = custommapper.class)     public void testmethod(int assertresult, string inputmark) {}      public static class custommapper extends identitymapper {         @override         public object[] map(reader reader) {             object[] map = super.map(reader);             list<object> result = new linkedlist<object>();             (object lineobj : map) {                 string line = lineobj.tostring();                 int index = line.indexof(",");                 string arg1 = line.substring(0, index);                 string arg2 = line.substring(index + 1, line.length());                 result.add(new object[] {arg1, arg2});             }             return result.toarray();         }     } } 

for more complex solution - should use regexp in custommapper parse csv data.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -