CurrentStepRunIndexProvider implements DynamicPropertyResolver.ValueProvider { @Override public String getValue(PropertyExpansionContext context) { if( context instanceof WsdlTestRunContext) { TestRunner runner = ((WsdlTestRunContext) context).getTestRunner(); if( runner instanceof AbstractTestCaseRunner) { List<TestStepResult> resultList = ((AbstractTestCaseRunner) runner).getResults(); TestStep currentStep = ((WsdlTestRunContext) context).getCurrentStep(); int ix = 0; for( TestStepResult result : resultList ) if( result.getTestStep().getId().equals( currentStep.getId())) ix++; return String.valueOf( ix ); } } return null; }  @Override String getValue(PropertyExpansionContext context);  }
@Test public void testProvider() { CurrentStepRunIndexProvider provider = new CurrentStepRunIndexProvider(); TestStep mockStep1 = Mockito.mock( TestStep.class ); Mockito.when( mockStep1.getId()).thenReturn( "1234" ); TestStep mockStep2 = Mockito.mock( TestStep.class ); Mockito.when( mockStep2.getId()).thenReturn( "2345" ); TestStepResult mockResult1 = Mockito.mock( TestStepResult.class ); Mockito.when( mockResult1.getTestStep()).thenReturn( mockStep1 ); TestStepResult mockResult2 = Mockito.mock( TestStepResult.class ); Mockito.when( mockResult2.getTestStep()).thenReturn( mockStep2 ); List<TestStepResult> resultList = new ArrayList<TestStepResult>(); resultList.add( mockResult1 ); resultList.add( mockResult2 ); resultList.add( mockResult2 ); resultList.add( mockResult1 ); resultList.add( mockResult2 ); WsdlTestRunContext context = Mockito.mock(WsdlTestRunContext.class); AbstractTestCaseRunner runner = Mockito.mock(AbstractTestCaseRunner.class); Mockito.when( context.getTestRunner() ).thenReturn( runner ); Mockito.when( runner.getResults()).thenReturn( resultList ); Mockito.when( context.getCurrentStep()).thenReturn(mockStep1); Assert.assertEquals( "2", provider.getValue( context )); Mockito.when( context.getCurrentStep()).thenReturn(mockStep2); Assert.assertEquals( "3", provider.getValue( context )); }