package Ġcz . enc irc led . j put . runner Ċ Ċ import Ġcz . enc irc led . j put . Test Reporter Ċ import Ġcz . enc irc led . j put . context . context Ċ import Ġcz . enc irc led . j put . runner . junit . J Put JUnit 4 Runner Ċ import Ġcz . enc irc led . j put . runner . junit . J Put Spring Runner Ċ import Ġcz . enc irc led . j put . runner . steps . J unit 4 TestRunner Steps Ċ import Ġorg . junit . BeforeClass Ċ import Ġorg . junit . Ignore Ċ import Ġorg . junit . runner . Description Ċ import Ġorg . junit . runner . notification . Failure Ċ import Ġorg . junit . runner . notification . Run Listener Ċ import Ġorg . junit . runner . notification . Run Notifier Ċ import Ġorg . springframework . context . annotation . Component Scan Ċ import Ġorg . springframework . context . annotation . Configuration Ċ import Ġkotlin . test .* Ċ Ċ class ĠTest Run Listener Ġ: ĠRun Listener () Ġ{ ĊĊĠĠĠ Ġval Ġfailures Ġ= Ġmutable ListOf < Failure >() ĊĊĠĠĠ Ġval Ġfinished Ġ= Ġmutable ListOf < Description >() ĊĊĠĠĠ Ġval Ġassumption Failures Ġ= Ġmutable ListOf < Failure >() ĊĊĠĠĠ Ġoverride Ġfun Ġtest Ass umption Failure ( failure : ĠFailure ) Ġ{ ĊĠĠĠĠĠĠĠ Ġassumption Failures . add ( failure ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġtest Finished ( description : ĠDescription ) Ġ{ ĊĠĠĠĠĠĠĠ Ġfinished . add ( description ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġtest Failure ( failure : ĠFailure ) Ġ{ ĊĠĠĠĠĠĠĠ Ġfailures . add ( failure ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ Ċ class ĠJ unit 4 TestRunner IntegrationTest Ġ: ĠBase IntegrationTest () Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ@ Jvm Static ĊĠĠĠĠĠĠĠ Ġ@ BeforeClass ĊĠĠĠĠĠĠĠ Ġfun Ġrun Steps () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrunner Ġ= ĠJ Put JUnit 4 Runner ( J unit 4 TestRunner Steps :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġnot ifier Ġ= ĠRun Notifier () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnot ifier . addListener ( listener ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrunner . run ( notifier ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ċ Ċ } ĊĊ Ċ class ĠSpring TestRunner IntegrationTest Ġ: ĠBase IntegrationTest () Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ@ Jvm Static ĊĠĠĠĠĠĠĠ Ġ@ BeforeClass ĊĠĠĠĠĠĠĠ Ġfun Ġrun Steps () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrunner Ġ= ĠJ Put Spring Runner ( J unit 4 TestRunner Steps :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġnot ifier Ġ= ĠRun Notifier () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnot ifier . addListener ( listener ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrunner . run ( notifier ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ċ Ċ } Ċ Ċ abstract Ġclass ĠBase IntegrationTest Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠĠĠĠĠ Ġlateinit Ġvar Ġlistener : ĠTest Run Listener ĊĊĠĠĠĠĠĠĠ Ġ@ Jvm Static ĊĠĠĠĠĠĠĠ Ġ@ BeforeClass ĊĠĠĠĠĠĠĠ Ġfun Ġbefore () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠJ unit 4 TestRunner Steps . test Counter Ġ= Ġ 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlistener Ġ= ĠTest Run Listener () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . init () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( context . result Report ers [ 0 ] Ġas ĠTest Reporter ). executions . clear () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( context . result Report ers [ 0 ] Ġas ĠTest Reporter ). inv ocations . clear () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠJ unit 4 TestRunner Steps . is Before Executed Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠTODO Ġother Ġas Ġwell ? ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Before Test Executed () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( J unit 4 TestRunner Steps . is Before Executed ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Ass umption Failed Propag ated () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġlistener . ass umption Failures . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" test Ass umption Failed Propag ated ", Ġlistener . ass umption Failures [ 0 ]. description . methodName ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest W arm Up And Repe ats Count () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Successful (" test W arm Up And Repe ats Count ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 4 , ĠJ unit 4 TestRunner Steps . test Counter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Ignored Test () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertFalse ( is Test Executed (" test Ignored Test ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Current Suite IsSet () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( J unit 4 TestRunner Steps :: class . java , Ġcontext . current Suite !!. clazz ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( context . current Suite !!. is Parallel ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Returned Error Propag ated () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġ" Limit Ġexceptions Ġcount Ġ= Ġ 1 , Ġactual Ġ= Ġ 1 0 0 0 " ĊĠĠĠĠĠĠĠ Ġassert Failed Assertion (" test Returned Error Propag ated ", Ġexpected ) ĊĠĠĠĠĠĠĠ Ġassert Exceptions In Runs (" test RuntimeException Cat ched ", Ġ" Test Ġexception ") ĊĊĠĠĠĠĠĠĠ Ġval Ġdetails Ġ= Ġget Execution (" test Returned Error Propag ated "). execution Result ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. values . map Ġ{ Ġit . result Details Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// ĠAssert Ġthat Ġresults Ġare Ġcorrectly Ġstored Ġin Ġparallel Ġexecution ĊĊĠĠĠĠĠĠĠ Ġdetails . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" Test Ġexception Ġ${ it . result Code }", Ġit . errorMessage ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 0 , Ġdetails . map Ġ{ Ġit . result Code Ġ}. distinct (). size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest RuntimeException Cat ched () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġ" Limit Ġexceptions Ġcount Ġ= Ġ 1 , Ġactual Ġ= Ġ 2 " ĊĠĠĠĠĠĠĠ Ġassert Failed Assertion (" test RuntimeException Cat ched ", Ġexpected ) ĊĠĠĠĠĠĠĠ Ġassert Exceptions In Runs (" test RuntimeException Cat ched ", Ġ" Test Ġexception ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Mark Performance Test Start () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Successful (" test Mark Performance Test Start ") ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġget Execution (" test Mark Performance Test Start "). get Elapsed Times (). size ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠTest Ġhas Ġthread . sleep ( 5 0 ) Ġand Ġthen Ġcalls Ġ' mark Performance Test Start ' ĊĠĠĠĠĠĠĠ ĠassertTrue ( get Execution (" test Mark Performance Test Start "). get Elapsed Times ()[ 0 ] Ġ< Ġ 4 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Ignore Ġ// ĠFIXME ĊĠĠĠ Ġfun Ġtest Mark Performance Test End () Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Successful (" test Mark Performance Test End ") ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġget Execution (" test Mark Performance Test End "). get Elapsed Times (). size ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠTest Ġcalls Ġ' mark Performance Test End ' Ġand Ġthen Ġthread . sleep ( 5 0 ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( get Execution (" test Mark Performance Test End "). get Elapsed Times ()[ 0 ] Ġ< Ġ 4 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Reporter Is Inv oked Correct ly () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreporter Ġ= Ġcontext . result Report ers [ 0 ] Ġas ĠTest Reporter ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmutable ListOf < Pair < String , ĠAny ?> >( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" before Class " Ġto ĠJ unit 4 TestRunner Steps :: class . java , ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" before Test " Ġto Ġ" J unit 4 TestRunner Steps # test Ass umption Failed Propag ated ", ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" before Test " Ġto Ġ" J unit 4 TestRunner Steps # test Mark Performance Test End ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" after Test " Ġto Ġ" J unit 4 TestRunner Steps # test Mark Performance Test End ", ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" before Test " Ġto Ġ" J unit 4 TestRunner Steps # test Mark Performance Test Start ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" after Test " Ġto Ġ" J unit 4 TestRunner Steps # test Mark Performance Test Start ", ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" before Test " Ġto Ġ" J unit 4 TestRunner Steps # test Returned Error Propag ated ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" after Test " Ġto Ġ" J unit 4 TestRunner Steps # test Returned Error Propag ated ", ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" before Test " Ġto Ġ" J unit 4 TestRunner Steps # test RuntimeException Cat ched ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" after Test " Ġto Ġ" J unit 4 TestRunner Steps # test RuntimeException Cat ched ", ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" before Test " Ġto Ġ" J unit 4 TestRunner Steps # test W arm Up And Repe ats Count ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" after Test " Ġto Ġ" J unit 4 TestRunner Steps # test W arm Up And Repe ats Count ", ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" after Class " Ġto ĠJ unit 4 TestRunner Steps :: class . java ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġreporter . inv ocations ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠAssert Ġthat Ġunit Ġtest Ġfailed Ġwith Ġgiven Ġ[ expected Assertion ] ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġfun Ġassert Failed Assertion ( method : ĠString , Ġexpected Assertion : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfailure Ġ= Ġexpect Failure ( method ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Performance Ġtest Ġfailed .\ n [$ expected Assertion ]", Ġfailure . exception . message ) ĊĊĠĠĠĠĠĠĠ Ġval Ġexecution Ġ= Ġget Execution ( method ) ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Violation Msg Ġ= Ġexecution . vi olations . join ToString Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . message Producer . invoke ( execution ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Assertion , Ġactual Violation Msg ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġassert Exceptions In Runs ( method : ĠString , Ġexpected Error : ĠString , ĠresultCode : ĠInt Ġ= Ġ 5 0 0 ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexecution Ġ= Ġget Execution ( method ) ĊĊĠĠĠĠĠĠĠ Ġexecution . execution Result . values . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( result Code , Ġit . result Details . result Code ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected Error , Ġit . result Details . errorMessage ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected Error , Ġit . result Details . error !!. message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġassert Successful ( method : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( listener . failures ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit . description . methodName Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. all Ġ{ Ġit Ġ!= Ġmethod Ġ}) ĊĊĠĠĠĠĠĠĠ Ġval Ġexecution Ġ= Ġget Execution ( method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( execution . vi olations . isEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( execution . execution Result . values . all Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . result Details . result Code Ġ== Ġ 2 0 0 Ġ&& ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit . result Details . error Ġ== Ġnull Ġ&& Ġit . result Details . errorMessage Ġ== Ġnull ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( is Test Executed ( method )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Execution ( id : ĠString ) Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( context . result Report ers [ 0 ] Ġas ĠTest Reporter ). get Execution ( id ) ĊĊĠĠĠ Ġprivate Ġfun Ġexpect Failure ( method : ĠString ): ĠFailure Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlistener . failures . first OrNull Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit . description . methodName Ġ== Ġmethod ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġ?: Ġfail (" Assertion Ġfailure Ġis Ġexpected Ġfor Ġ$ method ") ĊĊĠĠĠ Ġprivate Ġfun Ġis Test Executed ( method : ĠString ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġlistener . finished ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit . methodName Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. any Ġ{ Ġit Ġ== Ġmethod Ġ} ĊĠĠĠ Ġ} Ċ Ċ } Ċ Ċ @ Configuration Ċ @ Component Scan ( base Packages Ġ= Ġ[" cz . enc irc led . j put . spring . test "]) Ċ open Ġclass ĠConf