From 1fa7400faa8c99599d6f9add0984dc1f875fd42b Mon Sep 17 00:00:00 2001 From: Dai MIKURUBE Date: Tue, 17 Sep 2024 17:47:14 +0900 Subject: [PATCH] Tweak the classpath for embulkTest --- build.gradle | 21 ++++++++++++++++--- .../junit5/engine/EmbulkPluginTestEngine.java | 20 ++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 27b8ce2..91983a5 100644 --- a/build.gradle +++ b/build.gradle @@ -14,8 +14,8 @@ configurations { compileClasspath.resolutionStrategy.activateDependencyLocking() runtimeClasspath.resolutionStrategy.activateDependencyLocking() - embulkTestImplementation.extendsFrom testImplementation - embulkTestRuntime.extendsFrom testRuntime + // No need to declare "embulkTestImplementation" explicitly as the sourceSet "embulkTest" is declared below. + // No need to declare "embulkTestRuntime" explicitly as the sourceSet "embulkTest" is declared below. } sourceSets { @@ -44,9 +44,12 @@ dependencies { testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.11.0" - embulkTestImplementation project(":embulk-junit5-api") + embulkTestImplementation project(":embulk-junit5-api") // TODO: embulk-junit5-api depends on junit-jupiter-api transitively? + embulkTestImplementation "org.junit.jupiter:junit-jupiter-api:5.11.0" embulkTestRuntimeOnly project(":embulk-junit5-engine") + + // embulk-core can be loaded in the top-level class loader. embulkTestRuntimeOnly "org.embulk:embulk-core:0.11.5" } @@ -70,9 +73,21 @@ test { } task embulkTest(type: Test) { + doFirst { + println "^^^^^ Classpath information in embulkTest ^^^^^" + println sourceSets.embulkTest.runtimeClasspath + println sourceSets.embulkTest.runtimeClasspathConfigurationName + sourceSets.embulkTest.runtimeClasspath.each { + println it + } + println "^^^^^ Classpath information in embulkTest ^^^^^" + } + useJUnitPlatform() classpath = sourceSets.embulkTest.runtimeClasspath + + // Pick up "@EmbulkPluginTest" methods from the classes in "testClassesDirs" testClassesDirs = sourceSets.embulkTest.output.classesDirs testLogging { diff --git a/embulk-junit5-engine/src/main/java/org/embulk/junit5/engine/EmbulkPluginTestEngine.java b/embulk-junit5-engine/src/main/java/org/embulk/junit5/engine/EmbulkPluginTestEngine.java index cdfd84d..2d0b1ba 100644 --- a/embulk-junit5-engine/src/main/java/org/embulk/junit5/engine/EmbulkPluginTestEngine.java +++ b/embulk-junit5-engine/src/main/java/org/embulk/junit5/engine/EmbulkPluginTestEngine.java @@ -87,6 +87,26 @@ public TestDescriptor discover(final EngineDiscoveryRequest discoveryRequest, fi // final Class testClass = classSelector.getJavaClass(); // Not to get the Java class directly! final String testClassName = classSelector.getClassName(); + try { + System.out.println(Class.forName("org.embulk.input.junit5example.ExampleInputPlugin")); + } catch (final Exception ex) { + ex.printStackTrace(); + } + try { + System.out.println(Class.forName("org.embulk.input.junit5example.TestExample")); + } catch (final Exception ex) { + ex.printStackTrace(); + } + try { + System.out.println(Class.forName("org.embulk.input.junit5example.TestExample1")); + } catch (final Exception ex) { + ex.printStackTrace(); + } + try { + System.out.println(Class.forName("org.embulk.util.config.Config")); + } catch (final Exception ex) { + ex.printStackTrace(); + } final Class testClass = findOrLoadClassFrom(this.klassLoader, testClassName); final TestDescriptor classDescriptor =