title: Passing lambdas as testng parameters using DataProvider?
body: <p>I was wondering if there is a way to pass lambdas from testng's data providers. So I want to do something like the following:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @DataProvider(name="checkProvider")
      public Object[][] checkProvider() {
          return new Object[][]{
              "Some string to test", (String string) -&gt; string.length() &gt; 2 //A predicate on how to test response
          }
      }
  </code></pre>
  
  <p>And after that have some test like so</p>
  
  <pre class="lang-java prettyprint-override"><code>@Test(dataProvider="checkProvider")
  public void testsomething(String s, Predicate&lt;String&gt; checker) {
      //so some operation on s to get a string I want to check
      Assert.assertTrue(checker.check(someString));
  }
  </code></pre>
  
  <p>Right now I'm not able to do this as I get <em>Target type of lambda conversion must be an interface</em>.
  Does anyone have an idea on how to do this or even an alternative would be good so I could achieve the desired functionality.</p>
  
  <p>EDIT: The answer is in the first comment. I was trying to pass a lambda directly but if you first declare it and then pass it in Object[][] then it works fine.</p>