StringLengthFunction implements Function { public String execute(List<String> parameterList, TestContext context) { if (CollectionUtils.isEmpty(parameterList)) { throw new InvalidFunctionUsageException("Function parameters must not be empty"); } return String.valueOf((parameterList.get(0)).length()); }  String execute(List<String> parameterList, TestContext context);  }
@Test public void testFunction() { Assert.assertEquals(function.execute(Collections.singletonList("Hallo"), context), "5"); Assert.assertEquals(function.execute(Collections.singletonList("Hallo TestFramework!"), context), "20"); }
@Test(expectedExceptions = {InvalidFunctionUsageException.class}) public void testNoParameters() { function.execute(Collections.<String>emptyList(), context); }