package Ġfl ank . filter Ċ Ċ import Ġfl ank . filter . internal . from Test Targets Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertFalse Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Test Ċ import Ġjava . nio . file . Path Ċ import Ġjava . nio . file . Paths Ċ Ċ val ĠF OO _ PACKAGE : ĠTarget Ġ= Ġ" foo . ClassName # test Name " Ġto Ġempty List () Ċ val ĠBAR _ PACKAGE : ĠTarget Ġ= Ġ" bar . ClassName # test Name " Ġto Ġempty List () Ċ val ĠF OO _ CLASS NAME : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto Ġempty List () Ċ val ĠBAR _ CLASS NAME : ĠTarget Ġ= Ġ" wh atever . Bar # test Name " Ġto Ġempty List () Ċ val ĠWITHOUT _ IGNORE _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto Ġempty List () Ċ val ĠWITH _ IGNORE _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto ĠlistOf (" org . junit . Ignore ") Ċ val ĠWITH _ FOO _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto ĠlistOf (" Foo ") Ċ val ĠWITH _ BAR _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto ĠlistOf (" Bar ") Ċ val ĠWITHOUT _ FOO _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto Ġempty List () Ċ val ĠWITH _ FOO _ AN NOT ATION _ AND _ PACKAGE : ĠTarget Ġ= Ġ" foo . Bar # test Name " Ġto ĠlistOf (" Foo ") Ċ val ĠWITH _ LARGE _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto ĠlistOf (" android . test . suite builder . annotation . Large Test ") Ċ val ĠWITH _ MEDIUM _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto ĠlistOf (" android . support . test . filters . Medium Test ") Ċ val ĠWITH _ SMALL _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto ĠlistOf (" android x . test . filters . Small Test ") Ċ val ĠWITHOUT _ LARGE _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto Ġempty List () Ċ val ĠWITHOUT _ MEDIUM _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto Ġempty List () Ċ val ĠWITHOUT _ SMALL _ AN NOT ATION : ĠTarget Ġ= Ġ" wh atever . Foo # test Name " Ġto Ġempty List () Ċ const Ġval ĠTEST _ FILE Ġ= Ġ" src / test / resources / dummy - tests - file . txt " Ċ const Ġval ĠTEST _ FILE _ 2 Ġ= Ġ" src / test / resources / exclude - tests . txt " Ċ private Ġconst Ġval ĠIG NORE _ AN NOT ATION Ġ= Ġ" org . junit . Ignore " Ċ Ċ @ Suppress (" Too Many Functions ") Ċ class ĠFilter Kt Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġtargets Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠTarget s Helper ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpack Ġ= Ġ" any Package _ 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl Ġ= Ġ" any Class _ 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġm Ġ= Ġ" any Method _ 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġannotation Ġ= ĠIG NORE _ AN NOT ATION ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 2 ", Ġcl Ġ= Ġ" any Class _ 2 ", Ġm Ġ= Ġ" any Method _ 2 ", Ġannotation Ġ= Ġ" Foo "), ĊĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 3 ", Ġcl Ġ= Ġ" any Class _ 3 ", Ġm Ġ= Ġ" any Method _ 3 ", Ġannotation Ġ= Ġ" Bar "), ĊĠĠĠĠĠĠĠ ĠTarget s Helper ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpack Ġ= Ġ" any Package _ 4 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl Ġ= Ġ" any Class _ 4 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġm Ġ= Ġ" any Method _ 4 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġannotation Ġ= ĠIG NORE _ AN NOT ATION ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval Ġtest Method Set Ġ= Ġtargets . map Ġ{ ĠgetDefault TestMethod ( it . full View , Ġit . annotation ) Ġ} ĊĠĠĠ Ġprivate Ġval Ġcommon Expected Ġ= Ġtargets . map Ġ{ Ġit . full View Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Ignore Multiple Annotations () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtarget : ĠTarget Ġ= Ġ" com . example . app . Example Ui Test # test Fails " Ġto ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" org . junit . runner . RunWith ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" org . junit . Ignore ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" org . junit . Test ", ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Annotation Ġorg . junit . Ignore ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( target )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Package () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" package Ġfoo ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( FOO _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( BAR _ PACKAGE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Package Negative () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Package Ġfoo ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( FOO _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( BAR _ PACKAGE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By ClassName () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" class Ġwhatever . Foo ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( FOO _ CLASS NAME )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( BAR _ CLASS NAME )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By ClassName Negative () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Class Ġwhatever . Foo ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( FOO _ CLASS NAME )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( BAR _ CLASS NAME )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` empty Ġtargets Ġshould Ġnot Ġfilter Ġ@ Ignore Ġannotated Ġtests `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf ()) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ IGNORE _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITHOUT _ IGNORE _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Annotation () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" annotation ĠFoo , Bar ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ FOO _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ BAR _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ FOO _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Annotation With Spaces () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" annotation ĠFoo , ĠBar ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ FOO _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ BAR _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ FOO _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Size Large () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" size Ġlarge ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ LARGE _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ LARGE _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Size Medium () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" size Ġmedium ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ MEDIUM _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ MEDIUM _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Size Small () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" size Ġsmall ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ SMALL _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ SMALL _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġtest Filtering By Size Invalid Will Throw Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate TestCase s Filter ( listOf (" size Ġfoo ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Sizes () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" size Ġlarge , small ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ LARGE _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ SMALL _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ LARGE _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ SMALL _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Sizes With Space () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" size Ġlarge , Ġsmall ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ LARGE _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ SMALL _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ LARGE _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITHOUT _ SMALL _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġtest Filtering By Not Sizes Will Throw Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate TestCase s Filter ( listOf (" not Size Ġlarge ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering By Annotation Negative () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Annotation ĠFoo ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITH _ FOO _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITHOUT _ FOO _ AN NOT ATION )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġall Of Pro per ly Checks All Filters () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" package Ġfoo , bar ", Ġ" annotation ĠFoo ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( FOO _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( BAR _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( WITH _ FOO _ AN NOT ATION )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( WITH _ FOO _ AN NOT ATION _ AND _ PACKAGE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering FromFile Negative () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠgetPath ( TEST _ FILE ) ĊĠĠĠĠĠĠĠ Ġval ĠfilePath Ġ= Ġfile . toString () ĊĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" test File Ġ$ filePath ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( FOO _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( BAR _ PACKAGE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering FromFile () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠgetPath ( TEST _ FILE ) ĊĠĠĠĠĠĠĠ Ġval ĠfilePath Ġ= Ġfile . toString () ĊĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Test File Ġ$ filePath ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( FOO _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( BAR _ PACKAGE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġpassing Malformed Command Will Throw Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate TestCase s Filter ( listOf (" class = com . my . package ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġpassing Invalid Command Will Throw Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate TestCase s Filter ( listOf (" invalid Command Ġcom . my . package ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġclass Filter Overrides Not Annotation () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġfrom Test Targets ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" not Annotation ĠFoo ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" class Ġany Package _ 2 . any Class _ 2 # any Method _ 2 ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" class Ġany Package _ 3 . any Class _ 3 # any Method _ 3 " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġoutput Ġ= Ġmutable ListOf < String >() ĊĠĠĠĠĠĠĠ Ġval Ġfiltered Ġ= Ġtest Method Set . as Sequence (). filter Ġ{ Ġtest Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġfilter . should Run ( test ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoutput . add (""" $ result Ġ${ test . first } Ġ[ ${ filter . describe }] """) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult ĊĠĠĠĠĠĠĠ Ġ}. map Ġ{ Ġ" class Ġ${ it . first }" Ġ}. toList () ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" false Ġany Package _ 1 . any Class _ 1 # any Method _ 1 Ġ[ all Of Ġ[ not Ġ( with Annotation Ġ( Foo )), Ġany Of Ġ[ with ClassName Ġ( any Package _ 2 . any Class _ 2 # any Method _ 2 ), Ġwith ClassName Ġ( any Package _ 3 . any Class _ 3 # any Method _ 3 )] ]] ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" false Ġany Package _ 2 . any Class _ 2 # any Method _ 2 Ġ[ all Of Ġ[ not Ġ( with Annotation Ġ( Foo )), Ġany Of Ġ[ with ClassName Ġ( any Package _ 2 . any Class _ 2 # any Method _ 2 ), Ġwith ClassName Ġ( any Package _ 3 . any Class _ 3 # any Method _ 3 )] ]] ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" true Ġany Package _ 3 . any Class _ 3 # any Method _ 3 Ġ[ all Of Ġ[ not Ġ( with Annotation Ġ( Foo )), Ġany Of Ġ[ with ClassName Ġ( any Package _ 2 . any Class _ 2 # any Method _ 2 ), Ġwith ClassName Ġ( any Package _ 3 . any Class _ 3 # any Method _ 3 )] ]] ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" false Ġany Package _ 4 . any Class _ 4 # any Method _ 4 Ġ[ all Of Ġ[ not Ġ( with Annotation Ġ( Foo )), Ġany Of Ġ[ with ClassName Ġ( any Package _ 2 . any Class _ 2 # any Method _ 2 ), Ġwith ClassName Ġ( any Package _ 3 . any Class _ 3 # any Method _ 3 )] ]] " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( expected , Ġoutput ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf (" class Ġany Package _ 3 . any Class _ 3 # any Method _ 3 "), Ġfiltered ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnot Annotation Filter sWith Class () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Annotation ĠFoo ", Ġ" class Ġany Package _ 1 . any Class _ 1 # any Method _ 1 ")) ĊĠĠĠĠĠĠĠ Ġval Ġfiltered Ġ= Ġtest Method Set . with Filter ( filter ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf (" any Package _ 1 . any Class _ 1 # any Method _ 1 "), Ġfiltered ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnot Annotation Filters () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Annotation ĠM oo ")) ĊĠĠĠĠĠĠĠ Ġval Ġfiltered Ġ= Ġtest Method Set . with Filter ( filter , Ġen rich Ġ= Ġfalse ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( common Expected , Ġfiltered ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmethod Override Ignored () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( targets . map Ġ{ Ġit . method View Ġ}) ĊĠĠĠĠĠĠĠ Ġval Ġfiltered Ġ= Ġtest Method Set . with Filter ( filter ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( common Expected , Ġfiltered ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmultiple Classes Resolve To Methods () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( targets . map Ġ{ Ġit . class View Ġ}) ĊĠĠĠĠĠĠĠ Ġval Ġfiltered Ġ= Ġtest Method Set . with Filter ( filter ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( common Expected , Ġfiltered ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmultiple Packages Resolve To Methods () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( targets . map Ġ{ Ġit . package View Ġ}) ĊĠĠĠĠĠĠĠ Ġval Ġfiltered Ġ= Ġtest Method Set . with Filter ( filter ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( common Expected , Ġfiltered ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` by Ġdefault Ġ- Ġshould Ġcontain Ġmethod Ġannotated Ġwith Ġ@ Ignore `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġby Package Filter Ġ= Ġcreate TestCase s Filter ( targets . map Ġ{ Ġit . package View Ġ}) ĊĠĠĠĠĠĠĠ Ġval Ġby Class Filter Ġ= Ġcreate TestCase s Filter ( targets . map Ġ{ Ġit . class View Ġ}) ĊĠĠĠĠĠĠĠ Ġval Ġby Not Annotation Filter Ġ= Ġcreate TestCase s Filter ( listOf (" not Annotation ĠThere Is NoSuch Annotation ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġby Package Ġ= Ġtest Method Set . with Filter ( by Package Filter ) ĊĠĠĠĠĠĠĠ Ġval Ġby Class Ġ= Ġtest Method Set . with Filter ( by Class Filter ) ĊĠĠĠĠĠĠĠ Ġval Ġby Not Annotation Ġ= Ġtest Method Set . with Filter ( by Not Annotation Filter , Ġen rich Ġ= Ġfalse ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( common Expected , Ġby Package ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( common Expected , Ġby Class ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( common Expected , Ġby Not Annotation ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġfilter Ġtests Ġannotated Ġwith Ġ@ Ignore Ġif Ġuser Ġexplicitly Ġwant Ġto Ġdo Ġso `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġby Not Annotation Filter Ġ= Ġcreate TestCase s Filter ( listOf (" not Annotation Ġ$ IGNORE _ AN NOT ATION ")) ĊĠĠĠĠĠĠĠ Ġval Ġby Not Annotation Ġ= Ġtest Method Set . with Filter ( by Not Annotation Filter , Ġen rich Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġtargets . filter Not Ġ{ Ġit . annotation Ġ== ĠIG NORE _ AN NOT ATION Ġ}. map Ġ{ Ġit . full View Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( by Not Annotation , Ġexpected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering Class And Package Negative () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Package Ġfoo ", Ġ" not Class Ġwhatever . Bar ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( FOO _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( BAR _ CLASS NAME )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( BAR _ PACKAGE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Filtering Class And Package Negative FromFile () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠgetPath ( TEST _ FILE _ 2 ) Ġ// Ġcontents : Ġfoo Ġwhatever . Bar ĊĠĠĠĠĠĠĠ Ġval ĠfilePath Ġ= Ġfile . toString () ĊĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Test File Ġ$ filePath ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( FOO _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( BAR _ CLASS NAME )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( BAR _ PACKAGE )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` in clusion Ġfilter Ġshould Ġoverride Ġex clusion Ġfilter `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( listOf (" not Package Ġfoo ", Ġ" class Ġwhatever . Bar ")) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( FOO _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( filter ( BAR _ PACKAGE )) ĊĠĠĠĠĠĠĠ ĠassertTrue ( filter ( BAR _ CLASS NAME )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` with ClassName Ġshould Ġcorrectly Ġfilter Ġclasses Ġwith Ġsimilar Ġname `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġtest - targets : ĊĠĠĠĠĠĠĠ Ġ// ĠĠ Ġ- Ġclass Ġfoo . bar . Class 1 ĊĠĠĠĠĠĠĠ Ġ// Ġshould Ġfilter Ġfoo . bar . Class 1 1 , Ġfoo . bar . Class 1 0 1 Ġ... ĊĠĠĠĠĠĠĠ Ġ// Ġthe Ġsame Ġis Ġapplicable Ġfor Ġmethods ĊĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= Ġcreate TestCase s Filter ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" class Ġany Package _ 1 . any Class _ 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" class Ġany Package _ 3 . any Class _ 3 # any Method _ 3 " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġtests Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 1 ", Ġcl Ġ= Ġ" any Class _ 1 ", Ġm Ġ= Ġ" any Method _ 1 ", Ġannotation Ġ= Ġ" Foo "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 1 ", Ġcl Ġ= Ġ" any Class _ 1 ", Ġm Ġ= Ġ" any Method _ 2 ", Ġannotation Ġ= Ġ" Foo "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 1 ", Ġcl Ġ= Ġ" any Class _ 1 2 ", Ġm Ġ= Ġ" any Method _ 1 ", Ġannotation Ġ= Ġ" Bar "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 1 ", Ġcl Ġ= Ġ" any Class _ 1 2 ", Ġm Ġ= Ġ" any Method _ 1 2 ", Ġannotation Ġ= Ġ" Bar "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 3 ", Ġcl Ġ= Ġ" any Class _ 3 ", Ġm Ġ= Ġ" any Method _ 3 ", Ġannotation Ġ= Ġ" Bar "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 3 ", Ġcl Ġ= Ġ" any Class _ 3 ", Ġm Ġ= Ġ" any Method _ 3 2 ", Ġannotation Ġ= Ġ" Bar "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 3 ", Ġcl Ġ= Ġ" any Class _ 3 2 ", Ġm Ġ= Ġ" any Method _ 3 ", Ġannotation Ġ= Ġ" Bar "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTarget s Helper ( pack Ġ= Ġ" any Package _ 3 ", Ġcl Ġ= Ġ" any Class _ 3 2 ", Ġm Ġ= Ġ" any Method _ 3 2 ", Ġannotation Ġ= Ġ" Bar ") ĊĠĠĠĠĠĠĠ Ġ). map Ġ{ ĠgetDefault TestMethod ( it . full View , Ġit . annotation ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" any Package _ 1 . any Class _ 1 # any Method _ 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" any Package _ 1 . any Class _ 1 # any Method _ 2 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" any Package _ 3 . any Class _ 3 # any Method _ 3 " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġtests . with Filter ( filter ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( expected , Ġresult ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġfun ĠgetPath ( path : ĠString ): ĠPath Ġ= ĊĠĠĠ ĠPaths . get ( path ). to AbsolutePath (). normalize () Ċ Ċ private Ġfun ĠgetDefault TestMethod ( test Name : ĠString , Ġannotation : ĠString ): ĠTarget Ġ= ĊĠĠĠ Ġtest Name Ġto ĠlistOf ( annotation ) Ċ Ċ private Ġfun ĠList < Target >. add ( method : ĠTarget ) Ġ= ĠlistOf (* this . to Typed Array () Ġ+ Ġmethod ) Ċ Ċ private Ġfun ĠList < Target >. with Filter ( should Run : ĠShould Run , Ġen rich : ĠBoolean Ġ= Ġtrue ) Ġ= ĊĠĠĠ Ġif Ġ( en rich ) Ġadd ( getDefault TestMethod (" should . be # filtered ", Ġ" Any Annotation ")) ĊĠĠĠĠĠĠĠ Ġ. filter ( should Run ). map Ġ{ Ġit . first Ġ} ĊĠĠĠ Ġelse Ġthis ĊĠĠĠĠĠĠĠ Ġ. filter ( should Run ). map Ġ{ Ġit . first Ġ} Ċ Ċ private Ġclass ĠTarget s Helper ( ĊĠĠĠ Ġprivate Ġval Ġpack : ĠString , ĊĠĠĠ Ġprivate Ġval Ġcl : ĠString , ĊĠĠĠ Ġprivate Ġval Ġm : ĠString , ĊĠĠĠ Ġval Ġannotation : ĠString Ċ ) Ġ{ ĊĠĠĠ Ġval Ġclass View : ĠString ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ" class Ġ$ pack .$ cl " ĊĊĠĠĠ Ġval Ġpackage View : ĠString ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ" package Ġ$ pack " ĊĊĠĠĠ Ġval Ġmethod View : ĠString ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ" class Ġ$ full View " ĊĊĠĠĠ Ġval Ġfull View : ĠString ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ"$ pack .$ cl #$ m " Ċ } Ċ