Java 类org.junit.platform.engine.EngineDiscoveryRequest 实例源码

项目:jovial    文件:ClojureTestEngineTest.java   
@Test
public void selectingByNamespace() {
    EngineDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
        .selectors(selectNamespace("sample.other-test"))
        .build();
    UniqueId root = UniqueId.root("sample", "test");

    List<UniqueId> expectedIds = Stream.of(
        root.append("namespace", "sample.other-test"),
        root.append("namespace", "sample.other-test").append("name", "my-other-works"),
        root.append("namespace", "sample.other-test").append("name", "my-other-fails"),
        root.append("namespace", "sample.other-test").append("name", "my-other-error")
    ).collect(Collectors.toList());

    TestDescriptor descriptor = new ClojureTestEngine().discover(request, root);
    List<UniqueId> actualIds = descriptor.getAllDescendants().stream()
        .map(TestDescriptor::getUniqueId)
        .collect(Collectors.toList());

    assertEquals(expectedIds, actualIds);
}
项目:jovial    文件:ClojureTestEngineTest.java   
@Test
public void selectingByVar() {
    EngineDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
        .selectors(selectVar("sample.other-test", "my-other-works"))
        .build();
    UniqueId root = UniqueId.root("sample", "test");

    List<UniqueId> expectedIds = Stream.of(
        root.append("namespace", "sample.other-test"),
        root.append("namespace", "sample.other-test").append("name", "my-other-works")
    ).collect(Collectors.toList());

    TestDescriptor descriptor = new ClojureTestEngine().discover(request, root);
    List<UniqueId> actualIds = descriptor.getAllDescendants().stream()
        .map(TestDescriptor::getUniqueId)
        .collect(Collectors.toList());

    assertEquals(expectedIds, actualIds);
}
项目:jovial    文件:ClojureTestEngineTest.java   
@Test
public void filteringByNamespace() {
    Set<File> roots = Arrays.stream(System.getProperty("classpath.roots").split(File.pathSeparator))
        .map(File::new)
        .collect(Collectors.toSet());

    EngineDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
        .selectors(selectClasspathRoots(roots))
        .filters(includeNamespacePattern(".*other.*"))
        .build();
    UniqueId root = UniqueId.root("sample", "test");

    List<UniqueId> expectedIds = Stream.of(
        root.append("namespace", "sample.other-test"),
        root.append("namespace", "sample.other-test").append("name", "my-other-works"),
        root.append("namespace", "sample.other-test").append("name", "my-other-fails"),
        root.append("namespace", "sample.other-test").append("name", "my-other-error")
    ).collect(Collectors.toList());

    TestDescriptor descriptor = new ClojureTestEngine().discover(request, root);
    List<UniqueId> actualIds = descriptor.getAllDescendants().stream()
        .map(TestDescriptor::getUniqueId)
        .collect(Collectors.toList());

    assertEquals(expectedIds, actualIds);
}
项目:jovial    文件:ClojureTestEngineTest.java   
@Test
public void getsTagsFromMetadata() {
    Set<File> roots = Arrays.stream(System.getProperty("classpath.roots").split(File.pathSeparator))
        .map(File::new)
        .collect(Collectors.toSet());

    EngineDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
        .selectors(selectClasspathRoots(roots))
        .build();
    UniqueId root = UniqueId.root("sample", "test");

    Map<UniqueId, Set<TestTag>> expectedTags = new HashMap<>();
    expectedTags.put(root.append("namespace", "sample.core-test"), tags("integration"));
    expectedTags.put(root.append("namespace", "sample.other-test"), tags());
    expectedTags.put(root.append("namespace", "sample.core-test").append("name", "my-sample-works"), tags("integration"));
    expectedTags.put(root.append("namespace", "sample.core-test").append("name", "my-sample-fails"), tags());
    expectedTags.put(root.append("namespace", "sample.other-test").append("name", "my-other-works"), tags("unit"));
    expectedTags.put(root.append("namespace", "sample.other-test").append("name", "my-other-fails"), tags());
    expectedTags.put(root.append("namespace", "sample.other-test").append("name", "my-other-error"), tags("integration"));

    TestDescriptor descriptor = new ClojureTestEngine().discover(request, root);
    Map<UniqueId, Set<TestTag>> actualTags = descriptor.getAllDescendants().stream()
        .collect(Collectors.toMap(TestDescriptor::getUniqueId, TestDescriptor::getTags));

    assertEquals(expectedTags, actualTags);
}
项目:mastering-junit5    文件:MyCustomEngine.java   
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest,
        UniqueId uniqueId) {
    // Discover test(s) and return a TestDescriptor object
    TestDescriptor testDescriptor = new EngineDescriptor(uniqueId,
            "My test");
    return testDescriptor;
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:MyCustomEngine.java   
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest,
        UniqueId uniqueId) {
    // Discover test(s) and return a TestDescriptor object
    TestDescriptor testDescriptor = new EngineDescriptor(uniqueId,
            "My test");
    return testDescriptor;
}
项目:jovial    文件:ClojureTestEngineTest.java   
@Test
public void selectingByClasspathDir() {
    Set<File> roots = Arrays.stream(System.getProperty("classpath.roots").split(File.pathSeparator))
        .map(File::new)
        .collect(Collectors.toSet());

    EngineDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
        .selectors(selectClasspathRoots(roots))
        .build();
    UniqueId root = UniqueId.root("sample", "test");

    List<UniqueId> expectedIds = Stream.of(
        root.append("namespace", "sample.core-test"),
        root.append("namespace", "sample.other-test"),
        root.append("namespace", "sample.core-test").append("name", "my-sample-works"),
        root.append("namespace", "sample.core-test").append("name", "my-sample-fails"),
        root.append("namespace", "sample.other-test").append("name", "my-other-works"),
        root.append("namespace", "sample.other-test").append("name", "my-other-fails"),
        root.append("namespace", "sample.other-test").append("name", "my-other-error")
    ).collect(Collectors.toList());

    TestDescriptor descriptor = new ClojureTestEngine().discover(request, root);
    List<UniqueId> actualIds = descriptor.getAllDescendants().stream()
        .map(TestDescriptor::getUniqueId)
        .collect(Collectors.toList());

    assertEquals(expectedIds, actualIds);
}
项目:junit-pioneer    文件:TestEngineSpy.java   
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
    this.discoveryRequestForDiscovery = discoveryRequest;
    this.uniqueIdForDiscovery = uniqueId;

    UniqueId engineUniqueId = UniqueId.forEngine(ID);
    TestDescriptorStub engineDescriptor = new TestDescriptorStub(engineUniqueId, ID);
    TestDescriptorStub testDescriptor = new TestDescriptorStub(engineUniqueId.append("test", "test"), "test");
    engineDescriptor.addChild(testDescriptor);
    return engineDescriptor;
}
项目:junit-pioneer    文件:ExecutionEventRecorder.java   
public static List<ExecutionEvent> execute(TestEngine testEngine, EngineDiscoveryRequest discoveryRequest) {
    TestDescriptor engineTestDescriptor = testEngine.discover(discoveryRequest,
        UniqueId.forEngine(testEngine.getId()));
    ExecutionEventRecorder listener = new ExecutionEventRecorder();
    testEngine.execute(
        new ExecutionRequest(engineTestDescriptor, listener, discoveryRequest.getConfigurationParameters()));
    return listener.getExecutionEvents();
}
项目:junit5-samples    文件:Machine.java   
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
    TestDescriptor engine = new EngineDescriptor(uniqueId, getCaption());
    for (int i = 0; i < getScoops(discoveryRequest, 5); i++) {
        engine.addChild(new Scoop(engine.getUniqueId(), i, Flavor.random()));
    }
    return engine;
}
项目:jovial    文件:BaseClojureEngine.java   
@Override
public TestDescriptor discover(EngineDiscoveryRequest request, UniqueId uniqueId) {
    Object engine = getEngine(request.getConfigurationParameters());
    return (TestDescriptor) SimpleClojure.invoke(ENGINE_NS, "discover", engine, request, uniqueId);
}
项目:junit-pioneer    文件:TestEngineStub.java   
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
    return new TestDescriptorStub(UniqueId.forEngine(getId()), getId());
}
项目:junit5-samples    文件:Machine.java   
/**
 * Extract amount of scoops to generate.
 */
int getScoops(EngineDiscoveryRequest discoveryRequest, int defaultScoops) {
    ConfigurationParameters parameters = discoveryRequest.getConfigurationParameters();
    String scoops = parameters.get("scoops").orElse(Integer.toString(defaultScoops));
    return Integer.valueOf(scoops);
}