-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Each test method how has its own runner and reporter. Allows parallel…
… execution of test methods.
- Loading branch information
1 parent
38f5f39
commit 6906305
Showing
8 changed files
with
305 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,63 @@ | ||
package convey | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/smartystreets/goconvey/execution" | ||
) | ||
|
||
func TestMissingTopLevelGoTestReferenceCausesPanic(t *testing.T) { | ||
runner = execution.NewRunner() | ||
|
||
output := map[string]bool{} | ||
|
||
defer expectEqual(t, false, output["good"]) | ||
defer requireGoTestReference(t) | ||
|
||
Convey("Hi", func() { | ||
output["bad"] = true // this shouldn't happen | ||
}) | ||
} | ||
|
||
func requireGoTestReference(t *testing.T) { | ||
err := recover() | ||
if err == nil { | ||
t.Error("We should have recovered a panic here (because of a missing *testing.T reference)!") | ||
} else { | ||
expectEqual(t, execution.MissingGoTest, err) | ||
} | ||
} | ||
|
||
func TestMissingTopLevelGoTestReferenceAfterGoodExample(t *testing.T) { | ||
runner = execution.NewRunner() | ||
|
||
output := map[string]bool{} | ||
|
||
defer func() { | ||
expectEqual(t, true, output["good"]) | ||
expectEqual(t, false, output["bad"]) | ||
}() | ||
defer requireGoTestReference(t) | ||
|
||
Convey("Good example", t, func() { | ||
output["good"] = true | ||
}) | ||
|
||
Convey("Bad example", func() { | ||
output["bad"] = true // shouldn't happen | ||
}) | ||
} | ||
|
||
func TestExtraReferencePanics(t *testing.T) { | ||
runner = execution.NewRunner() | ||
output := map[string]bool{} | ||
|
||
defer func() { | ||
err := recover() | ||
if err == nil { | ||
t.Error("We should have recovered a panic here (because of an extra *testing.T reference)!") | ||
} else if !strings.HasPrefix(fmt.Sprintf("%v", err), execution.ExtraGoTest) { | ||
t.Error("Should have panicked with the 'extra go test' error!") | ||
} | ||
if output["bad"] { | ||
t.Error("We should NOT have run the bad example!") | ||
} | ||
}() | ||
|
||
Convey("Good example", t, func() { | ||
Convey("Bad example - passing in *testing.T a second time!", t, func() { | ||
output["bad"] = true // shouldn't happen | ||
}) | ||
}) | ||
} | ||
// TODO: get these working again: | ||
|
||
// func TestMissingTopLevelGoTestReferenceCausesPanic(t *testing.T) { | ||
// output := map[string]bool{} | ||
|
||
// defer expectEqual(t, false, output["good"]) | ||
// defer requireGoTestReference(t) | ||
|
||
// Convey("Hi", func() { | ||
// output["bad"] = true // this shouldn't happen | ||
// }) | ||
// } | ||
|
||
// func requireGoTestReference(t *testing.T) { | ||
// err := recover() | ||
// if err == nil { | ||
// t.Error("We should have recovered a panic here (because of a missing *testing.T reference)!") | ||
// } else { | ||
// expectEqual(t, execution.MissingGoTest, err) | ||
// } | ||
// } | ||
|
||
// func TestMissingTopLevelGoTestReferenceAfterGoodExample(t *testing.T) { | ||
// output := map[string]bool{} | ||
|
||
// defer func() { | ||
// expectEqual(t, true, output["good"]) | ||
// expectEqual(t, false, output["bad"]) | ||
// }() | ||
// defer requireGoTestReference(t) | ||
|
||
// Convey("Good example", t, func() { | ||
// output["good"] = true | ||
// }) | ||
|
||
// Convey("Bad example", func() { | ||
// output["bad"] = true // shouldn't happen | ||
// }) | ||
// } | ||
|
||
// func TestExtraReferencePanics(t *testing.T) { | ||
// output := map[string]bool{} | ||
|
||
// defer func() { | ||
// err := recover() | ||
// if err == nil { | ||
// t.Error("We should have recovered a panic here (because of an extra *testing.T reference)!") | ||
// } else if !strings.HasPrefix(fmt.Sprintf("%v", err), execution.ExtraGoTest) { | ||
// t.Error("Should have panicked with the 'extra go test' error!") | ||
// } | ||
// if output["bad"] { | ||
// t.Error("We should NOT have run the bad example!") | ||
// } | ||
// }() | ||
|
||
// Convey("Good example", t, func() { | ||
// Convey("Bad example - passing in *testing.T a second time!", t, func() { | ||
// output["bad"] = true // shouldn't happen | ||
// }) | ||
// }) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.