Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSL for nested tests #13

Open
fogfish opened this issue Apr 29, 2023 · 0 comments
Open

DSL for nested tests #13

fogfish opened this issue Apr 29, 2023 · 0 comments

Comments

@fogfish
Copy link
Owner

fogfish commented Apr 29, 2023

Let's consider the following test

func TestXXX(t *testing.T) {
   t.Run("foo", func(t *testing.T) { /* ... */ })
   t.Run("bar", func(t *testing.T) { /* ... */ })
   ...
}

It would be useful to has DSL for

func TestXXX(t *testing.T) {
   t.Run("foo", it.Then(t).Should(/* ... */))
   t.Run("bar", it.Then(t).Should(/* ... */))  
   ...
}

or even

func TestXXX(t *testing.T) {
   it.Ok("foo", t).Should(/* ... */))
   it.Ok("bar", t).Should(/* ... */))
   ...
}

Given syntax simplifies definition of table tests. Full example

func TestXXX(t *testing.T) {

Seq := func(t *testing.T, /* input for test */) it.SeqOf[SomeType] { /* ... common testing function ... */ }

 it.Ok("foo", t).Should(
    Seq(t, /*... */).Equal(/* ... expected results */)
 )

 it.Ok("bar", t).Should(
    Seq(t, /*... */).Equal(/* ... expected results */)
 )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant