Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalatest-junit-runner does not work with Gradle Test Distribution #88

Closed
rpalcolea opened this issue Sep 20, 2022 · 5 comments · Fixed by #91
Closed

scalatest-junit-runner does not work with Gradle Test Distribution #88

rpalcolea opened this issue Sep 20, 2022 · 5 comments · Fixed by #91
Assignees

Comments

@rpalcolea
Copy link

rpalcolea commented Sep 20, 2022

Using Gradle Test Distribution Enterprise feature is not possible with the engine.

Given a build like this one:

plugins {
    id 'scala'
    id 'java-library'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.scala-lang:scala-library:2.12.8"
    testImplementation "org.scalatest:scalatest_2.12:3.2.0"
    testImplementation "org.scalatest:scalatest-flatspec_2.12:3.2.0"
    testImplementation "org.junit.platform:junit-platform-launcher:1.6.0"
    testRuntimeOnly "org.junit.platform:junit-platform-engine:1.6.0"
    testRuntimeOnly "co.helmethair:scalatest-junit-runner:0.1.11"
}

test {
    useJUnitPlatform {
        includeEngines 'scalatest'
        testLogging {
            events("passed", "skipped", "failed")
        }
    }
}

and a simple test:

class SomeCodeTest extends AnyFunSpec with Matchers {
  describe("someLibraryMethod") {
    it("always true") {
      def library = new Library()
      assert(library.someLibraryMethod())
    }
  }
}

The JUnit platform integration works as expected. However, when I enable test distribution, the tests are not executed

Session 2 opened on remote executor <executor id>
Partition 1 started on remote executor <executor id>
Partition 1 finished on remote executor<executor id> (passed = true, retries = 0)
Receiving output file <folder>/scala-testing/lib/build/test-distribution-outputs/test/test-results18149238746365984750/test-results2 from remote executor <executor id>
Finished receiving output file <folder>/scala-testing/lib/build/test-distribution-outputs/test/test-results18149238746365984750/test-results2 with size 111 bytes from remote executor <executor id>
Session 2 closed on remote executor <executor id>

The build is reported as successful and no tests are executed

From conversation with @marcphilip , he pointed out that the following might be happening:

It seems like the limitation is because scalatest-junit-runner only handles ClassSelectors is not able to run tests selected via unique ID: https://github.com/helmethair-co/scalatest-junit-runner/blob/f2de1f0cd4fd8587b13ae[…]f974/src/main/java/co/helmethair/scalatest/ScalatestEngine.java

It would need to check for UniqueIdSelectors in EngineDiscoveryRequest and map those to classes as well.

Unfortunately, because Test Distribution is an Enterprise issue, it is difficult to provide a reproducible

@giurim giurim added the bug Something isn't working label Sep 26, 2022
@giurim giurim self-assigned this Sep 26, 2022
@giurim giurim removed the bug Something isn't working label Sep 26, 2022
@giurim
Copy link
Contributor

giurim commented Sep 26, 2022

Related: #94

@giurim
Copy link
Contributor

giurim commented Sep 26, 2022

Thank you for the report, once #91 is merged can you please try Gradle Test Distribution again?

@rpalcolea
Copy link
Author

Hi @giurim , yeah! absolutely! I'll keep an eye on it

@rpalcolea
Copy link
Author

Actually, went ahead and published a local snapshot of the branch and looks good to me, at least from initial assessment:

Distributed Test Run :lib:test > Partition 1 in session 2 on <Remote agent UUID> > SomeCodeTest > someLibraryMethod is always true always true PASSED

And have proper XML files

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="scala.testing.SomeCodeTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2022-09-26T21:41:34" hostname="Robertos-MacBook-Pro.local" time="0.03">
  <properties/>
  <testcase name="someLibraryMethod is always true always true" classname="scala.testing.SomeCodeTest" time="0.03"/>
  <system-out><![CDATA[]]></system-out>
  <system-err><![CDATA[]]></system-err>
</testsuite>

@giurim
Copy link
Contributor

giurim commented Sep 27, 2022

Thank you @rpalcolea , great news!

@giurim giurim linked a pull request Sep 27, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants