Search in sources :

Example 1 with ClasspathResourceSelector

use of org.junit.platform.engine.discovery.ClasspathResourceSelector in project junit5 by junit-team.

the class SuiteLauncherDiscoveryRequestBuilderTests method selectClasspathResource.

@Test
void selectClasspathResource() {
    @SelectClasspathResource("com.example.testcases")
    class Suite {
    }
    LauncherDiscoveryRequest request = builder.suite(Suite.class).build();
    List<ClasspathResourceSelector> selectors = request.getSelectorsByType(ClasspathResourceSelector.class);
    assertEquals("com.example.testcases", exactlyOne(selectors).getClasspathResourceName());
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ClasspathResourceSelector(org.junit.platform.engine.discovery.ClasspathResourceSelector) SelectClasspathResource(org.junit.platform.suite.api.SelectClasspathResource) Test(org.junit.jupiter.api.Test)

Example 2 with ClasspathResourceSelector

use of org.junit.platform.engine.discovery.ClasspathResourceSelector in project junit5 by junit-team.

the class SuiteLauncherDiscoveryRequestBuilderTests method selectClasspathResourcePosition.

@Test
void selectClasspathResourcePosition() {
    @SelectClasspathResource(value = "com.example.testcases", line = 42)
    @SelectClasspathResource(value = "com.example.testcases", line = 14, column = 15)
    class Suite {
    }
    LauncherDiscoveryRequest request = builder.suite(Suite.class).build();
    List<ClasspathResourceSelector> selectors = request.getSelectorsByType(ClasspathResourceSelector.class);
    assertEquals(Optional.of(FilePosition.from(42)), selectors.get(0).getPosition());
    assertEquals(Optional.of(FilePosition.from(14, 15)), selectors.get(1).getPosition());
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ClasspathResourceSelector(org.junit.platform.engine.discovery.ClasspathResourceSelector) SelectClasspathResource(org.junit.platform.suite.api.SelectClasspathResource) Test(org.junit.jupiter.api.Test)

Example 3 with ClasspathResourceSelector

use of org.junit.platform.engine.discovery.ClasspathResourceSelector in project junit5 by junit-team.

the class DiscoveryRequestCreatorTests method convertsClasspathResourceSelectors.

@Test
void convertsClasspathResourceSelectors() {
    options.setSelectedClasspathResources(asList("foo.csv", "com/example/bar.json"));
    LauncherDiscoveryRequest request = convert();
    List<ClasspathResourceSelector> classpathResourceSelectors = request.getSelectorsByType(ClasspathResourceSelector.class);
    assertThat(classpathResourceSelectors).extracting(ClasspathResourceSelector::getClasspathResourceName).containsExactly("foo.csv", "com/example/bar.json");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ClasspathResourceSelector(org.junit.platform.engine.discovery.ClasspathResourceSelector) Test(org.junit.jupiter.api.Test)

Example 4 with ClasspathResourceSelector

use of org.junit.platform.engine.discovery.ClasspathResourceSelector in project junit5 by junit-team.

the class SuiteLauncherDiscoveryRequestBuilderTests method ignoreClasspathResourcePosition.

@Test
void ignoreClasspathResourcePosition() {
    @SelectClasspathResource(value = "com.example.testcases", line = -1)
    @SelectClasspathResource(value = "com.example.testcases", column = 12)
    @SelectClasspathResource(value = "com.example.testcases", line = 42, column = -12)
    class Suite {
    }
    LauncherDiscoveryRequest request = builder.suite(Suite.class).build();
    List<ClasspathResourceSelector> selectors = request.getSelectorsByType(ClasspathResourceSelector.class);
    assertEquals(Optional.empty(), selectors.get(0).getPosition());
    assertEquals(Optional.empty(), selectors.get(1).getPosition());
    assertEquals(Optional.of(FilePosition.from(42)), selectors.get(2).getPosition());
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ClasspathResourceSelector(org.junit.platform.engine.discovery.ClasspathResourceSelector) SelectClasspathResource(org.junit.platform.suite.api.SelectClasspathResource) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 ClasspathResourceSelector (org.junit.platform.engine.discovery.ClasspathResourceSelector)4 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)4 SelectClasspathResource (org.junit.platform.suite.api.SelectClasspathResource)3