kazurayam / selenium-webdriver-java

Examples of the O'Reilly book "Hands-On Selenium WebDriver with Java"
https://oreil.ly/1E7CX
Apache License 2.0
0 stars 0 forks source link

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

Open kazurayam opened 9 months ago

kazurayam commented 9 months ago

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