franela/goblin

If a test doesn't have a handle function, consider it "PENDING"

xetorthio opened this issue · 5 comments

If a test doesn't have a handle function, consider it "PENDING"

I've been doing some research and it doesn't seem to be a nice way to implement this.
Go doesn't support conditional parameters or even parameters with default value. Also it doesn't support method overloading, so I don't see how we could do something like this:

g.Describe("Something", func() {
    g.It("This will be considered pending")
})

The handler is mandatory.

I thought about 3 options.

First

g.Describe("Something", func() {
    g.It("This will be considered pending", func() {
        g.Pending()
    })
})

Second

g.Describe("Something", func() {
    g.It("This will be considered pending", Pending)
})

Third

g.Describe("Something", func() {
    g.Pending("This will be considered pending")
})

Any other idea?

I've seen some other testing frameworks doing things like:

g.Describe("Something", func() {
    g.It("This will be considered pending", nil)
})

But I don't like it very much.

What do you think about this approach?:

package main

import "fmt"

func main() {
    It("Should print pending ")
    It("Shound print hola", func() {fmt.Println("Hola")})
}


func It(name string, h ...func()) {
    if len(h) == 0 {
        fmt.Println("Pending")
    } else {
        h[0]()
    }
}

Yes. This is the best one so far!
Lets go with that! I like it!
On Oct 1, 2013 1:37 AM, "Marcos Nils" notifications@github.com wrote:

I've seen some other testing frameworks doing things like:

g.Describe("Something", func() {
g.It("This will be considered pending", nil)})

But I don't like it very much.

What do you think about this approach?:

package main
import "fmt"
func main() {
It("Should print pending ")
It("Shound print hola", func() {fmt.Println("Hola")}) }

func It(name string, h ...func()) {
if len(h) == 0 {
fmt.Println("Pending")
} else {
h0
}}


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-25426605
.

👍

should be implemented by #13