private List < Runner > addDynamicClasses ( final RunnerBuilder builder , final ContractTestMap contractTestMap , final Dynamic dynamic ) throws InitializationError { final Class < ? extends Dynamic > dynamicClass = dynamic . getClass ( ) ; // this is the list of all the JUnit runners in the suite. final List < Runner > runners = new ArrayList < Runner > ( ) ; ContractImpl impl = getContractImpl ( dynamicClass ) ; if ( impl == null ) { return runners ; } final DynamicSuiteInfo dynamicSuiteInfo = new DynamicSuiteInfo ( dynamicClass , impl ) ; final Collection < Class < ? > > tests = dynamic . getSuiteClasses ( ) ; if ( ( tests == null ) || ( tests . size ( ) == 0 ) ) { dynamicSuiteInfo . addError ( new InitializationError ( "Dynamic suite did not return a list of classes to execute" ) ) ; runners . add ( new TestInfoErrorRunner ( dynamicClass , dynamicSuiteInfo ) ) ; } else { for ( final Class < ? > test : tests ) { final RunWith runwith = test . getAnnotation ( RunWith . class ) ; if ( ( runwith != null ) && runwith . value ( ) . equals ( ContractSuite . class ) ) { impl = getContractImpl ( test ) ; if ( impl != null ) { final DynamicTestInfo parentTestInfo = new DynamicTestInfo ( test , impl , dynamicSuiteInfo ) ; if ( ! parentTestInfo . hasErrors ( ) ) { addSpecifiedClasses ( runners , test , builder , contractTestMap , dynamic , parentTestInfo ) ; } // this is not an else as addSpecifiedClasses may add // errors to parentTestInfo if ( parentTestInfo . hasErrors ( ) ) { runners . add ( new TestInfoErrorRunner ( dynamicClass , parentTestInfo ) ) ; } } } else { try { runners . add ( builder . runnerForClass ( test ) ) ; } catch ( final Throwable t ) { throw new InitializationError ( t ) ; } } } } return runners ; }
Add dynamic classes to the suite .