package Ġcom . four last or . pickle Ċ Ċ import Ġcom . google . common . io . Resources Ċ import Ġcom . google . testing . compile . Compilation Ċ import Ġcom . google . testing . compile . Compilation Subject Ċ import Ġcom . google . testing . compile . Compilation Subject . assertThat Ċ import Ġcom . google . testing . compile . Compiler . javac Ċ import Ġcom . google . testing . compile . Java File Objects Ċ import Ġcom . squareup . jav ap o et . Annotation Spec Ċ import Ġcom . squareup . jav ap o et . Field Spec Ċ import Ġcom . squareup . jav ap o et . Java File Ċ import Ġcom . squareup . jav ap o et . Type Spec Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . Runner Ċ import Ġjavax . lang . model . element . Modifier Ċ import Ġjavax . tools . Java FileObject Ċ Ċ class ĠPick le Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġfeatures Dir Ġ= Ġfeatures Dir (" features ") ĊĠĠĠ Ġprivate Ġval Ġstrict Ġ= Ġtrue ĊĠĠĠ Ġprivate Ġval Ġnon Strict Ġ= Ġfalse ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With Defined Steps () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠpackageName Ġ= Ġ" target " ĊĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠpackageName , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstrict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Steps . java ", Ġ" steps / Other Steps . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). successfully Generated Test Classes ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature Without Background Test . java ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature With Background Test . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With Missing Defined Steps In Strict Mode () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" target ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstrict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Steps . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). failed () ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Error Containing (" Missing Ġstep Ġdefinition Ġfor Ġ\" A Ġstep Ġfrom Ġanother Ġdefinition Ġfile \" ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With Amb iguous Defined Steps In Strict Mode () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" target ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstrict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Steps . java ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Other Steps . java ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Other Step sWith Amb iguous Step . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). failed () ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Error Containing (""" Ċ Pick le ĠError : ĊĠ ĠMultiple Ġstep Ġimplementations Ġmatched . ĊĠ Ġ> ĠStep Ġdefinition : Ġ" A Ġstep Ġwith Ġ 1 Ġas Ġparameter " ĊĠ Ġ> ĠStep Ġimplementation Ġwith Ġregex es : ĊĠ Ġ^ A Ġstep Ġwith Ġ(\ w +) Ġas Ġparameter $ ĊĠ Ġ^ A Ġstep Ġwith Ġ(\ w ?) Ġas Ġparameter $ ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With Missing Defined Steps In Non Strict Mode () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠpackageName Ġ= Ġ" target For Non Strict Mode " ĊĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠpackageName , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnon Strict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Steps . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). succeeded () ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Warning Containing (""" Ċ Missing Ġstep Ġdefinition Ġfor Ġ" A Ġstep Ġfrom Ġanother Ġdefinition Ġfile " ĊĠ Ġ" Scenario : ĠScenario Ġwith Ġone Ġstep Ġand Ġbackground " Ġwill Ġbe Ġskipped . ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). successfully Generated Test Classes ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature Without Background Test . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With All Defined Steps Missing In Non Strict Mode () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠpackageName Ġ= Ġ" target For Non Strict Mode All Steps Missing " ĊĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠpackageName , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnon Strict ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). succeeded () ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Warning Containing (" Missing Ġstep Ġdefinition Ġfor Ġ\" A Ġstep Ġwithout Ġparameters \" ") ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Warning Containing (" Missing Ġstep Ġdefinition Ġfor Ġ\" A Ġstep Ġwith Ġ 1 Ġas Ġparameter \" ") ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Warning Containing (" Missing Ġstep Ġdefinition Ġfor Ġ\" A Ġstep Ġwith Ġ 2 Ġas Ġparameter \" ") ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Warning Containing (" Missing Ġstep Ġdefinition Ġfor Ġ\" A Ġstep Ġwithout Ġparameters \" ") ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Warning Containing (" Missing Ġstep Ġdefinition Ġfor Ġ\" A Ġstep Ġwith Ġ 1 Ġas Ġparameter \" ") ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Warning Containing (" Missing Ġstep Ġdefinition Ġfor Ġ\" A Ġstep Ġwith Ġa Ġas Ġparameter \" ") ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). successfully Generated Test Classes ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature Without Background Test . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With Defined Steps And Hooks () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠpackageName Ġ= Ġ" target With Hooks " ĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠpackageName , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstrict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Steps . java ", Ġ" steps / Other Step sWith Hooks . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). successfully Generated Test Classes ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature Without Background Test . java ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature With Background Test . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With Defined Steps And Hooks From Separ ate File () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠpackageName Ġ= Ġ" target With Separ ate Hooks " ĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠpackageName , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstrict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Steps . java ", Ġ" steps / Other Steps . java ", Ġ" steps / Just Hooks . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). successfully Generated Test Classes ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature Without Background Test . java ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature With Background Test . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With Duplicate Sc enarios () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir (" features Duplicate Scenario "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" target ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstrict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Steps . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). failed () ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Error Containing (""" Ċ Pick le ĠError : ĊĠ ĠSc enarios Ġneed Ġto Ġhave Ġunique Ġnames . ĊĠ ĠDuplicate Ġscenarios : ĊĠ Ġ> ĠDuplicate Ġscenario ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfeature With Step Definition Arguments Mismatch () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" target ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstrict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Steps . java ", Ġ" steps / Other Step sWith Wrong Arguments . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). failed () ĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). had Error Containing (""" Ċ Pick le ĠError : ĊĠ ĠStep Ġdefinition Ġargument Ġmismatch . ĊĠ Ġ> ĠStep Ġdefinition : Ġ" A Ġstep Ġfrom Ġanother Ġdefinition Ġfile " ĊĠ Ġ> ĠStep Ġimplementation : Ġsteps . Other Step sWith Wrong Arguments . a Step From Another Definition File ( java . lang . String ) ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdeprecated Annotations Sup po orted () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠpackageName Ġ= Ġ" target Deprecated " ĊĊĠĠĠĠĠĠĠ Ġval Ġcompilation Ġ= Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Dir , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠpackageName , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstrict , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" steps / Deprecated Steps . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compilation ). successfully Generated Test Classes ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature Without Background Test . java ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ packageName / A Feature With Background Test . java " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfeatures Dir ( dir Name : ĠString ) Ġ= ĠResources . getResource ( dir Name ). path ĊĊĠĠĠ Ġprivate Ġfun Ġwhen Comp iling With ( ĊĠĠĠĠĠĠĠ Ġfeatures Dir : ĠString , ĊĠĠĠĠĠĠĠ Ġtarget PackageName : ĠString , ĊĠĠĠĠĠĠĠ Ġstrict Mode : ĠBoolean , ĊĠĠĠĠĠĠĠ Ġvar arg Ġavailable Steps : ĠString ĊĠĠĠ Ġ): ĠCompilation Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsteps Definitions Ġ= Ġavailable Steps ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠJava File Objects . for Resource ( it ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. to Typed Array () ĊĊĠĠĠĠĠĠĠ Ġreturn Ġjav ac () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Processors ( Pick le Processor ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. compile ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpickle Configuration ( features Dir , Ġtarget PackageName , Ġstrict Mode ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġandroid JUnit 4 (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ* steps Definitions ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġpickle Configuration ( features Dir : ĠString , ĠpackageName : ĠString , Ġstrict Mode : ĠBoolean ): ĠJava FileObject Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcreate Class (" Pick le Hash ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Annotation ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAnnotation Spec . builder ( Pick le :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Member (" features Dir ", Ġ"\ $ S ", Ġfeatures Dir ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Member (" packageName ", Ġ"\ $ S ", ĠpackageName ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Member (" strict Mode ", Ġ"\ $ L ", Ġstrict Mode ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Field ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠField Spec . builder ( Int :: class . java , Ġ" HASH _ CODE ", ĠModifier . PRIVATE , ĠModifier . STATIC , ĠModifier . FINAL ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. initializer ("\ $ L ", Ġ 1 2 3 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ}. as Java FileObject () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġandroid JUnit 4 (): ĠJava FileObject Ġ= ĊĠĠĠĠĠĠĠ Ġcreate Class (" Android JUnit 4 ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsuperclass ( Runner :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Modifiers ( Modifier . PUBLIC , ĠModifier . AB STR ACT ) ĊĠĠĠĠĠĠĠ Ġ}. as Java FileObject (" android x . test . ext . junit . runners ") ĊĊĠĠĠ Ġprivate Ġfun ĠType Spec . as Java FileObject ( packageName : ĠString Ġ= Ġ" com . example "): ĠJava FileObject Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjava File Ġ= ĠJava File . builder ( packageName , Ġthis ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ Ġreturn ĠJava File Objects . for Source String ("${ java File . packageName }. $ name ", Ġjava File . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠCompilation Subject . successfully Generated Test Classes ( var arg Ġtest Classes : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsucceeded () ĊĊĠĠĠĠĠĠĠ Ġtest Classes . forEach Ġ{ Ġtest Class Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfully QualifiedName Ġ= Ġtest Class . remove Suffix (". java ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. replace ('/', Ġ'.') ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtest Class Source Ġ= ĠJava File Objects . for Resource ( test Class ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġgenerated SourceFile ( fully QualifiedName ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Source Equivalent To ( test Class Source ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ