Search code examples
gobddginkgo

Ginkgo skipped specs counted as failed


I've being using Ginkgo for a while and I have found a behavior I don't really understand. I have a set of specs that I only want to run if and only if a condition is available. If the condition is not available I want to skip the test suite.

Something like this:

   ginkgo.BeforeSuite(func(){
    if !CheckCondition() {
        ginkgo.Skip("condition not available")
    } 
   }

When the suite is skipped this counts as a failure.

FAIL! -- 0 Passed | 1 Failed | 0 Pending | 0 Skipped

I assumed there should be one tests to be considered to be skipped. Am I missing something? Any comments are welcome.

Thnaks


Solution

  • I think you are using Skip method incorrectly. It should be use inside spec like below, not inside BeforeSuite. When used inside spec it does show up as "skipped" in the summary.

    It("should do something, if it can", func() {
        if !someCondition {
            Skip("special condition wasn't met")
        }
    })
    

    https://onsi.github.io/ginkgo/#the-spec-runner