Skip to content

Commit

Permalink
remove TestConstructorDetector that has been made obsolete by JUnit 5…
Browse files Browse the repository at this point in the history
….5 InvocationInterceptor

Signed-off-by: Jonas Höf <[email protected]>
  • Loading branch information
jonashoef committed Dec 9, 2024
1 parent 0d090b4 commit f80020b
Showing 1 changed file with 24 additions and 59 deletions.
83 changes: 24 additions & 59 deletions doc/junit5-reproducible-test-class-and-method-cycle.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ participant "Test A" as T_A
participant "Test B" as T_B

participant "VPExtension\n(JUnit5)" as VPF_X #lightblue
participant "TestConstructorDetector" as TCD
note over TCD: to detect test class instantiation\nand switch to test method cycle
participant "ValueProviderFactory" as VPF
note over VPF: Just shown for single thread,\nimplemented as ThreadLocal\nfor parallel test execution
participant "DefaultInitializationCreator" as D_VPC
Expand Down Expand Up @@ -34,26 +32,14 @@ VPF -> C_VPC : startTestCycle
C_VPC -> C_VPC : initialize seed &\n reference date/time
note right of C_VPC #lightgreen: using system properties
VPF -> VPF : activateCreator(TestClassInitializationCreator)
VPF_X -> TCD : instantiation
activate TCD
VPF_X -> VPF : activateTestConstructorDetector

T_A -> VPF : createRandomValueProvider
note left #lightgreen: static initialization
VPF -> TCD : isCallFromTestConstructor
TCD --> VPF : false
VPF -> C_VPC : createRandomValueProvider

== Test A test method <1> ==
JVM --> T_A : instantiation for test method <1>
activate T_A

T_A -> VPF : createRandomValueProvider
note left #lightgreen: instance variables

VPF -> TCD : isCallFromTestConstructor
TCD --> VPF : true
VPF -> VPF : startTestMethodCycle
JVM -> VPF_X : interceptTestClassConstructor
VPF_X -> VPF : startTestMethodCycle
VPF -> VPF : activateCreator(TestMethodInitializationCreator)
VPF -> M_VPC : startTestCycle(TestClassInitializationCreator)
M_VPC -> M_VPC : initialize seed &\n reference date/time
Expand All @@ -62,13 +48,13 @@ M_VPC -> M_VPC : copyValueProviderSuffixes(TestClassInitializationCreator)
note right of M_VPC #lightgreen: required to ensure unique suffixes
M_VPC -> M_VPC : copyReferenceDateTime(TestClassInitializationCreator)
note right of M_VPC #lightgreen: required to ensure reproducible\ndate/time related test data
VPF -> VPF : deactivateTestConstructorDetector
VPF --> TCD
destroy TCD
VPF -> M_VPC : createRandomValueProvider
JVM <-- VPF_X : proceed
JVM --> T_A : instantiation for test method <1>
activate T_A

JVM -> VPF_X : postProcessTestInstance
note over VPF_X : nothing to do, if TestConstructorDetector\nswitched to test method cycle already
T_A -> VPF : createRandomValueProvider
note left #lightgreen: instance variables
VPF -> M_VPC : createRandomValueProvider

T_A -> VPF : createRandomValueProvider
note left #lightgreen: before methods
Expand All @@ -85,24 +71,14 @@ VPF_X -> VPF : finishTestMethodCycle
VPF -> M_VPC : finishTestCycle
M_VPC -> M_VPC : resetValueProviderSuffixes
VPF -> VPF : activateCreator(TestClassInitializationCreator)
VPF_X -> TCD : instantiation
activate TCD
VPF_X -> VPF : activateTestConstructorDetector

JVM --> T_A : destruction for test method <1>
destroy T_A
newpage

== Test A test method <2> ==
JVM --> T_A : instantiation for test method <2>
activate T_A

T_A -> VPF : createRandomValueProvider
note left #lightgreen: instance variables

VPF -> TCD : isCallFromTestConstructor
TCD --> VPF : true
VPF -> VPF : startTestMethodCycle
JVM -> VPF_X : interceptTestClassConstructor
VPF_X -> VPF : startTestMethodCycle
VPF -> VPF : activateCreator(TestMethodInitializationCreator)
VPF -> M_VPC : startTestCycle(TestClassInitializationCreator)
M_VPC -> M_VPC : initialize seed &\n reference date/time
Expand All @@ -111,13 +87,13 @@ M_VPC -> M_VPC : copyValueProviderSuffixes(TestClassInitializationCreator)
note right of M_VPC #lightgreen: required to ensure unique suffixes
M_VPC -> M_VPC : copyReferenceDateTime(TestClassInitializationCreator)
note right of M_VPC #lightgreen: required to ensure reproducible\ndate/time related test data
VPF -> VPF : deactivateTestConstructorDetector
VPF --> TCD
destroy TCD
VPF -> M_VPC : createRandomValueProvider
JVM <-- VPF_X : proceed
JVM --> T_A : instantiation for test method <2>
activate T_A

JVM -> VPF_X : postProcessTestInstance
note over VPF_X : nothing to do, if TestConstructorDetector\nswitched to test method cycle already
T_A -> VPF : createRandomValueProvider
note left #lightgreen: instance variables
VPF -> M_VPC : createRandomValueProvider

T_A -> VPF : createRandomValueProvider
note left #lightgreen: before methods
Expand All @@ -134,8 +110,6 @@ VPF_X -> VPF : finishTestMethodCycle
VPF -> M_VPC : finishTestCycle
M_VPC -> M_VPC : resetValueProviderSuffixes
VPF -> VPF : activateCreator(TestClassInitializationCreator)
VPF_X -> TCD : instantiation
activate TCD

JVM --> T_A : destruction for test method <2>
destroy T_A
Expand All @@ -146,9 +120,6 @@ C_VPC -> C_VPC : resetValueProviderSuffixes
VPF -> VPF : delete TestClassInitializationCreator
destroy C_VPC
VPF -> VPF : activateCreator(DefaultInitializationCreator)
VPF_X -> VPF : deactivateTestConstructorDetector
VPF --> TCD
destroy TCD
JVM --> VPF_X
destroy VPF_X
newpage
Expand All @@ -165,26 +136,13 @@ VPF -> C_VPC : startTestCycle
C_VPC -> C_VPC : initialize seed &\n reference date/time
note right of C_VPC #lightgreen: using system properties
VPF -> VPF : activateCreator(TestClassInitializationCreator)
VPF_X -> TCD : instantiation
activate TCD
VPF_X -> VPF : activateTestConstructorDetector

T_B -> VPF : createRandomValueProvider
note left #lightgreen: static initialization
VPF -> TCD : isCallFromTestConstructor
TCD --> VPF : false
VPF -> C_VPC : createRandomValueProvider

== Test B test method <1> ==
JVM --> T_B : instantiation for test method <1>
activate T_B

JVM -> VPF_X : postProcessTestInstance
note over VPF_X : variant: if no VPs were created after test instatiation,\nmust switch to test method cycle here
VPF_X -> VPF : deactivateTestConstructorDetector
VPF --> TCD
destroy TCD

JVM -> VPF_X : interceptTestClassConstructor
VPF_X -> VPF : startTestMethodCycle
VPF -> VPF : activateCreator(TestMethodInitializationCreator)
VPF -> M_VPC : startTestCycle(TestClassInitializationCreator)
Expand All @@ -194,6 +152,13 @@ M_VPC -> M_VPC : copyValueProviderSuffixes(TestClassInitializationCreator)
note right of M_VPC #lightgreen: required to ensure unique suffixes
M_VPC -> M_VPC : copyReferenceDateTime(TestClassInitializationCreator)
note right of M_VPC #lightgreen: required to ensure reproducible\ndate/time related test data
JVM <-- VPF_X : proceed
JVM --> T_B : instantiation for test method <1>
activate T_B

T_B -> VPF : createRandomValueProvider
note left #lightgreen: instance variables
VPF -> M_VPC : createRandomValueProvider

T_B -> VPF : createRandomValueProvider
note left #lightgreen: before methods
Expand Down

0 comments on commit f80020b

Please sign in to comment.