Skip to content

Gradle task "testSelective" that execute selected tests only to finish quickly #24

@kazurayam

Description

@kazurayam

I want to run the test classes that output files into disk.

If I run all test classes by $ gradle :selenium-webdriver-junit4:test takes over 20 minutes to finish. It's too long for me to wait.

So I want to select the classes that output files and run them exclusively.

I wrote in the -junit4 subproject the following custom Gradle task that does what I want.

task testSelective(type: Test) {
    useJUnit()

    include '**/ch04/event_listeners/MyEventListener*'
    include '**/ch04/screenshots/ScreenshotPng*'
    include '**/ch04/screenshots/WebElementScreenshot*'
    include '**/ch05/cdp/FullPageScreenshotChrome*'
    include '**/ch05/cdp/FullPageScreenshotFirefox*'
    include '**/ch05/print/PrintChrome*'
    include '**/ch05/print/PrintEdge*'
    include '**/ch05/print/PrintFirefox*'
    include '**/ch09/accessibility/Accessibility*'
    include '**/ch09/download/DownloadFirefox*'
    include '**/ch09/download/DownloadHttpClient*'
    include '**/ch09/performance/HarCreator*'
    include '**/ch09/reporting/Reporting*'
}

Looks OK. I took only 1m 45 secs.

I want to do the same in other subprojects: -junit5, -junit5-seljup and -testng

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions