diff --git a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtension.kt b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtension.kt index 6f3042e..58db8eb 100644 --- a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtension.kt +++ b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtension.kt @@ -34,7 +34,6 @@ class RobolectricExtension : InvocationInterceptor, BeforeAllCallback, BeforeEac "beforeEach ${context.requiredTestClass.simpleName}::${context.requiredTestMethod.name}" } val testRunnerHelper = testRunnerHelper(context.requiredTestClass) - testRunnerHelper.createTestEnvironmentForMethod(context.requiredTestMethod) testRunnerHelper.runOnMainThreadWithRobolectric(context.requiredTestMethod) { testRunnerHelper.beforeEach(context.requiredTestMethod) } diff --git a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunnerHelper.kt b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunnerHelper.kt index 5c3985e..ed21e4f 100644 --- a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunnerHelper.kt +++ b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunnerHelper.kt @@ -20,8 +20,6 @@ import java.util.concurrent.ConcurrentHashMap internal class JUnit5RobolectricTestRunnerHelper(testClass: Class<*>) { private inline val logger get() = createLogger() private var _robolectricTestRunner: JUnit5RobolectricTestRunner? = null - private var _sdkEnvironment: Sandbox? = null - private var _frameworkMethod: FrameworkMethod? = null init { validateNestedTestClassCanNotOverrideRuntimeSdk(testClass) @@ -30,10 +28,6 @@ internal class JUnit5RobolectricTestRunnerHelper(testClass: Class<*>) { @VisibleForTesting val robolectricTestRunner: JUnit5RobolectricTestRunner get() = requireNotNull(_robolectricTestRunner) - val sdkEnvironment: Sandbox get() = requireNotNull(_sdkEnvironment) - - @VisibleForTesting - val frameworkMethod: FrameworkMethod get() = requireNotNull(_frameworkMethod) fun sdkEnvironment(testMethod: Method?): Sandbox { return if (testMethod == null) { @@ -62,16 +56,6 @@ internal class JUnit5RobolectricTestRunnerHelper(testClass: Class<*>) { private fun createTestEnvironmentForClass(testClass: Class<*>) { _robolectricTestRunner = JUnit5RobolectricTestRunner(testClass) - // _sdkEnvironment = robolectricTestRunner.bootstrapSdkEnvironment() - // logger.trace { "$sdkEnvironment createTestEnvironmentForClass" } - } - - fun createTestEnvironmentForMethod(testMethod: Method) { - // val frameworkMethod = robolectricTestRunner.frameworkMethod(testMethod) - - // _sdkEnvironment = robolectricTestRunner.sdkEnvironment(frameworkMethod) - // _frameworkMethod = frameworkMethod - // logger.trace { "$sdkEnvironment createTestEnvironmentForMethod" } } fun beforeEach(testMethod: Method) { @@ -98,8 +82,6 @@ internal class JUnit5RobolectricTestRunnerHelper(testClass: Class<*>) { fun clearCachedRobolectricTestRunnerEnvironment() { _robolectricTestRunner = null - _sdkEnvironment = null - _frameworkMethod = null } internal companion object { diff --git a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/JUnit5RobolectricRunnerHelperTest.kt b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/JUnit5RobolectricRunnerHelperTest.kt index 0b1e354..24792b4 100644 --- a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/JUnit5RobolectricRunnerHelperTest.kt +++ b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/JUnit5RobolectricRunnerHelperTest.kt @@ -104,21 +104,13 @@ class JUnit5RobolectricRunnerHelperTest { fun `Given the runnerHelper configured when call clear then the runnerHelper should be empty`() { // Given val testClass = TwoTestMethodsJunitJupiterTest::class.java - val testMethod2 = testClass.declaredMethods.first { - it.name == TwoTestMethodsJunitJupiterTest::testMethod2.name - } val runnerHelper = subjectUnderTest(testClass) { - // And - createTestEnvironmentForMethod(testMethod2) - // When clearCachedRobolectricTestRunnerEnvironment() } // Then assertThrows { runnerHelper.robolectricTestRunner } - assertThrows { runnerHelper.sdkEnvironment } - assertThrows { runnerHelper.frameworkMethod } } private fun subjectUnderTest(