Skip to content

Commit

Permalink
Remove RobolectricTestRunner.getConfig(Method)
Browse files Browse the repository at this point in the history
This method is deprecated, and had an alternative provided in its comment.
  • Loading branch information
MGaetan89 authored and utzcoz committed Mar 14, 2024
1 parent 1405644 commit a13a8db
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.robolectric.pluginapi.config.ConfigurationStrategy;
import org.robolectric.pluginapi.config.ConfigurationStrategy.Configuration;
import org.robolectric.pluginapi.config.GlobalConfigProvider;
import org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl;
import org.robolectric.util.Logger;
import org.robolectric.util.PerfStatsCollector;
import org.robolectric.util.ReflectionHelpers;
Expand Down Expand Up @@ -411,42 +410,9 @@ public static AndroidManifest createAndroidManifest(ManifestIdentifier manifestI
manifestIdentifier.getApkFile());
}

/**
* Compute the effective Robolectric configuration for a given test method.
*
* <p>Configuration information is collected from package-level {@code robolectric.properties}
* files and {@link Config} annotations on test classes, superclasses, and methods.
*
* <p>Custom TestRunner subclasses may wish to override this method to provide alternate
* configuration.
*
* @param method the test method
* @return the effective Robolectric configuration for the given test method
* @deprecated Provide an implementation of {@link javax.inject.Provider<Config>} instead. This
* method will be removed in Robolectric 4.3.
* @since 2.0
* @see <a href="http://robolectric.org/migrating/#migrating-to-40">Migration Notes</a> for more
* details.
*/
@Deprecated
public Config getConfig(Method method) {
throw new UnsupportedOperationException();
}

/** Calculate the configuration for a given test method. */
private Configuration getConfiguration(Method method) {
Configuration configuration =
configurationStrategy.getConfig(getTestClass().getJavaClass(), method);

// in case #getConfig(Method) has been overridden...
try {
Config config = getConfig(method);
((ConfigurationImpl) configuration).put(Config.class, config);
} catch (UnsupportedOperationException e) {
// no problem
}

return configuration;
return configurationStrategy.getConfig(getTestClass().getJavaClass(), method);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import org.junit.runners.model.FrameworkMethod;
import org.robolectric.RobolectricTestRunner.RobolectricFrameworkMethod;
import org.robolectric.android.internal.AndroidTestEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Config.Implementation;
import org.robolectric.annotation.experimental.LazyApplication;
import org.robolectric.annotation.experimental.LazyApplication.LazyLoad;
import org.robolectric.config.ConfigurationRegistry;
Expand Down Expand Up @@ -142,20 +140,6 @@ public void testsWithUnsupportedSdkShouldBeIgnored() throws Exception {
.inOrder();
}

@Test
public void supportsOldGetConfigUntil4dot3() throws Exception {
Implementation overriddenConfig = Config.Builder.defaults().build();
List<FrameworkMethod> children = new SingleSdkRobolectricTestRunner(TestWithTwoMethods.class) {
@Override
public Config getConfig(Method method) {
return overriddenConfig;
}
}.getChildren();
Config config = ((RobolectricFrameworkMethod) children.get(0))
.getConfiguration().get(Config.class);
assertThat(config).isSameInstanceAs(overriddenConfig);
}

@Test
public void failureInResetterDoesntBreakAllTests() throws Exception {
RobolectricTestRunner runner =
Expand Down

0 comments on commit a13a8db

Please sign in to comment.