@@ -56,10 +56,23 @@ private LifecycleHooks() {
5656 }
5757 }
5858
59- public static void premain (String args , Instrumentation instrumentation ) {
59+ /**
60+ * This is the main entry point for the Java agent used to transform {@code ParentRunner} and
61+ * {@code BlockJUnit4ClassRunner}.
62+ *
63+ * @param agentArgs agent options
64+ * @param instrumentation {@link Instrumentation} object used to transform JUnit core classes
65+ */
66+ public static void premain (String agentArgs , Instrumentation instrumentation ) {
6067 installTransformer (instrumentation );
6168 }
6269
70+ /**
71+ * Install the {@code Byte Buddy} byte code transformations that provide test fine-grained test lifecycle hooks.
72+ *
73+ * @param instrumentation {@link Instrumentation} object used to transform JUnit core classes
74+ * @return The installed class file transformer
75+ */
6376 public static ClassFileTransformer installTransformer (Instrumentation instrumentation ) {
6477 TypeDescription type1 = TypePool .Default .ofClassPath ().describe ("org.junit.runners.ParentRunner" ).resolve ();
6578 TypeDescription type2 = TypePool .Default .ofClassPath ().describe ("org.junit.runners.BlockJUnit4ClassRunner" ).resolve ();
@@ -105,6 +118,10 @@ static synchronized JUnitConfig getConfig() {
105118 return config ;
106119 }
107120
121+ /**
122+ * This class declares the interceptor for the {@link org.junit.runners.ParentRunner#createTestClass
123+ * createTestClass} method.
124+ */
108125 @ SuppressWarnings ("squid:S1118" )
109126 public static class CreateTestClass {
110127 static final ServiceLoader <TestClassWatcher > classWatcherLoader ;
@@ -114,6 +131,14 @@ public static class CreateTestClass {
114131 classWatcherLoader = ServiceLoader .load (TestClassWatcher .class );
115132 }
116133
134+ /**
135+ * Interceptor for the {@link org.junit.runners.ParentRunner#createTestClass createTestClass} method.
136+ *
137+ * @param runner underlying test runner
138+ * @param proxy callable proxy for the intercepted method
139+ * @return new {@link TestClass} object
140+ * @throws Exception if something goes wrong
141+ */
117142 public static TestClass intercept (@ This Object runner , @ SuperCall Callable <?> proxy ) throws Exception {
118143 TestClass testClass = (TestClass ) proxy .call ();
119144 CLASS_TO_RUNNER .put (testClass , runner );
@@ -126,6 +151,9 @@ public static TestClass intercept(@This Object runner, @SuperCall Callable<?> pr
126151 }
127152 }
128153
154+ /**
155+ * This class declares the interceptor for the {@link org.junit.runners.ParentRunner#run run} method.
156+ */
129157 @ SuppressWarnings ("squid:S1118" )
130158 public static class Run {
131159 static final ServiceLoader <RunListener > runListenerLoader ;
@@ -135,6 +163,14 @@ public static class Run {
135163 runListenerLoader = ServiceLoader .load (RunListener .class );
136164 }
137165
166+ /**
167+ * Interceptor for the {@link org.junit.runners.ParentRunner#run run} method.
168+ *
169+ * @param runner underlying test runner
170+ * @param proxy callable proxy for the intercepted method
171+ * @param notifier run notifier through which events are published
172+ * @throws Exception if something goes wrong
173+ */
138174 public static void intercept (@ This Object runner , @ SuperCall Callable <?> proxy , @ Argument (0 ) RunNotifier notifier ) throws Exception {
139175 if (NOTIFIERS .add (notifier )) {
140176 Description description = invoke (runner , "getDescription" );
@@ -210,6 +246,13 @@ public static Object getRunnerFor(TestClass testClass) {
210246 throw new IllegalStateException ("No associated runner was for for specified test class" );
211247 }
212248
249+ /**
250+ * Get the description of the indicated child object from the runner for the specified test class instance.
251+ *
252+ * @param instance test class instance
253+ * @param child child object
254+ * @return {@link Description} object for the indicated child
255+ */
213256 public static Description describeChild (Object instance , Object child ) {
214257 TestClass testClass = getTestClassFor (instance );
215258 Object runner = getRunnerFor (testClass );
0 commit comments