mirror of
https://github.com/stretchr/testify.git
synced 2025-09-04 19:35:26 +00:00
## Summary This test case verifies that the Passed method returns false when all tests in the suite fail ## Changes Added a test case to check the scenario where all tests fail. ## Motivation This test is important to ensure that the Passed method correctly identifies the overall failure state of a test suite when none of the individual tests pass. ## Example usage This test can be used as a part of the test suite to validate the behavior of the Passed method under failure conditions. ## Related issues None
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package suite
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPassedReturnsTrueWhenAllTestsPass(t *testing.T) {
|
|
sinfo := newSuiteInformation()
|
|
sinfo.TestStats = map[string]*TestInformation{
|
|
"Test1": {TestName: "Test1", Passed: true},
|
|
"Test2": {TestName: "Test2", Passed: true},
|
|
"Test3": {TestName: "Test3", Passed: true},
|
|
}
|
|
|
|
assert.True(t, sinfo.Passed())
|
|
}
|
|
|
|
func TestPassedReturnsFalseWhenSomeTestFails(t *testing.T) {
|
|
sinfo := newSuiteInformation()
|
|
sinfo.TestStats = map[string]*TestInformation{
|
|
"Test1": {TestName: "Test1", Passed: true},
|
|
"Test2": {TestName: "Test2", Passed: false},
|
|
"Test3": {TestName: "Test3", Passed: true},
|
|
}
|
|
|
|
assert.False(t, sinfo.Passed())
|
|
}
|
|
|
|
func TestPassedReturnsFalseWhenAllTestsFail(t *testing.T) {
|
|
sinfo := newSuiteInformation()
|
|
sinfo.TestStats = map[string]*TestInformation{
|
|
"Test1": {TestName: "Test1", Passed: false},
|
|
"Test2": {TestName: "Test2", Passed: false},
|
|
"Test3": {TestName: "Test3", Passed: false},
|
|
}
|
|
|
|
assert.False(t, sinfo.Passed())
|
|
}
|