java 8 - TestNG data provider with folder contents using lambda -


i want give list of file names through testng data provider, test can load each file.

object[][] result = files.list(paths.get("tst/resources/json"))             .filter(files::isregularfile)             .map(filename -> new object[] { filename })             .toarray(object[][]::new); 

i've got point can build object[][] folder contents, testng throws exception:

org.testng.internal.reflect.methodmatcherexception:  data provider mismatch method: testfbtinka11interpretjson([parameter{index=0,  type=java.lang.string, declaredannotations=[]}]) arguments: [(sun.nio.fs.windowspath$windowspathwithattributes)tst\resources\json\admin.json]  @ org.testng.internal.reflect.dataprovidermethodmatcher.getconformingarguments(dataprovidermethodmatcher.java:52) 

...

it looks me @test method using data provider accepting file names string data provider providing file object , breaking.

you have 2 options:

  1. you change @test method accept file object instead of string. (or)
  2. you change data provider start providing absolute paths of file objects instead of file object. i.e., change .map(filename -> new object[] { filename }) .map(filename -> new object[] { filename.getabsolutepath() })

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -