lundi 9 mars 2020

Force to execute task inside the test when spock test timeout

As titled

For example, I have below test cases.

class StartupTest {

    @Timeout(80)
    def 'Start_test'() {

    setup:
    //do some setup here

    when: 'Test_started'
    //do something here

    and: 'Check_something'
    //check something here

    then: 'Validate_something'
    //validate something here

    cleanup:
    //Call the function in another class to zip the file and send out message to slack
    ZipUploader.Slack()   

   }
}

So if the test run within 80sec, the function in cleanup can be execute successfully, but I also want the function to execute even the test exceed timeout, I don't know how to achieve it.

It will just stopped the whole test in the middle if the test exceed timeout and return timeout exception, and the function under cleanup: will not be executed.

Aucun commentaire:

Enregistrer un commentaire