Search in sources :

Example 1 with AndroidTestPackage

use of com.android.tools.idea.testartifacts.junit.AndroidTestPackage in project android by JetBrains.

the class AndroidTestAndJUnitConfigurationConflictsTest method checkClassesInAllInPackage.

private void checkClassesInAllInPackage(TestSearchScope type) throws CantRunException {
    Module module = ModuleManager.getInstance(myFixture.getProject()).findModuleByName("app");
    assertNotNull(module);
    AndroidJUnitConfiguration configuration = createConfiguration(getProject(), "google.simpleapplication", module);
    configuration.getPersistentData().setScope(type);
    AndroidTestPackage testPackage = new AndroidTestPackage(configuration, ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), configuration).build());
    Set<PsiClass> myClasses = new HashSet<>();
    ConfigurationUtil.findAllTestClasses(testPackage.getClassFilter(configuration.getPersistentData()), null, myClasses);
    assertSize(1, myClasses);
    TestArtifactSearchScopes scopes = TestArtifactSearchScopes.get(module);
    assertNotNull(scopes);
    assertTrue(scopes.isUnitTestSource(myClasses.iterator().next().getContainingFile().getVirtualFile()));
}
Also used : TestArtifactSearchScopes(com.android.tools.idea.testartifacts.scopes.TestArtifactSearchScopes) PsiClass(com.intellij.psi.PsiClass) AndroidTestPackage(com.android.tools.idea.testartifacts.junit.AndroidTestPackage) AndroidJUnitConfiguration(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration) Module(com.intellij.openapi.module.Module) HashSet(java.util.HashSet)

Aggregations

AndroidJUnitConfiguration (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration)1 AndroidTestPackage (com.android.tools.idea.testartifacts.junit.AndroidTestPackage)1 TestArtifactSearchScopes (com.android.tools.idea.testartifacts.scopes.TestArtifactSearchScopes)1 Module (com.intellij.openapi.module.Module)1 PsiClass (com.intellij.psi.PsiClass)1 HashSet (java.util.HashSet)1