mardi 1 septembre 2020

How to rerun only failed tests in go testing

I have a package with several files and tests. Currently to rerun failed tests I'm using:

func TestMain(m *testing.M) {
    var r int = -1
    maxRuns := 3
    for i := 0; i < maxRuns && r != 0; i++ {
        r = m.Run()
    }
    os.Exit(r)
}

Actually it works, however it reruns all package tests in a single test failure scenario. So sometimes it leads to the next sequence: PASSED,PASSED,FAILED. This way the test marked as FAILED. My goal is to rerun only failed tests in a package, mark it as PASSED at the moment of a first success, mark test as FAILED only in case of a triple failure. Any suggestion?

Aucun commentaire:

Enregistrer un commentaire