kazurayam / materialstore

A domain-specific file system to store "materials" (screenshots, HTML, JSON, XML) collected during End-to-End testings using Selenium WebDriver etc. Features to make "diff" and compiling HTML reports are also included. This is written in pure Java8
Apache License 2.0
0 stars 0 forks source link

How to create a custom Gradle task `mytest` that can include/exclude matching test classes #351

Closed kazurayam closed 1 year ago

kazurayam commented 1 year ago

For #350 , I edited the base/build.gradle and inserted the following lines:

test {
    filter {
        includeTestsMatching("*reduce.MaterialProductGroup_BuilderTest")
        includeTestsMatching("*reduce.MaterialProductGroup_issue87Test")
    }
}

This worked fine.

Buit I wanted to create a custom task mytest which does the same above while leaving the original test task as original. So I modified

task mytest(type:Test) {
    filter {
        includeTestsMatching("*reduce.MaterialProductGroup_BuilderTest")
        includeTestsMatching("*reduce.MaterialProductGroup_issue87Test")
    }
}

This does not work.

$ gradle mytest
> Task :base:mytest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':base:mytest'.
> No tests found for given includes: [*reduce.MaterialProductGroup_issue87Test, *reduce.MaterialProductGroup_BuilderTest](filter.includeTestsMatching)

How should I write the mytest task?

kazurayam commented 1 year ago

The following worked:

task testFiltered(type:Test) {
    useJUnitPlatform()
    filter {
        includeTestsMatching("*reduce.MaterialProductGroup_BuilderTest")
        includeTestsMatching("*reduce.MaterialProductGroup_issue87Test")
    }
}