Skip to content

Commit

Permalink
fixes #13 aftereach not running
Browse files Browse the repository at this point in the history
 - also adds tests to verify that beforeach/aftereach/setup and teardown are run as expected
  • Loading branch information
George Cook committed Oct 1, 2018
1 parent e9f42a4 commit 309dbb5
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 8 deletions.
4 changes: 2 additions & 2 deletions samples/Overview/source/rooibos.cat.brs
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ function RBS_ItG_GetRunnableTestSuite(group) as object
runnableSuite.SetUp = RBS_CMN_GetFunction(group.setupFunction, group.setupFunctionName)
runnableSuite.TearDown = RBS_CMN_GetFunction(group.teardownFunction, group.teardownFunctionName)
runnableSuite.BeforeEach = RBS_CMN_GetFunction(group.beforeEachFunction, group.beforeEachFunctionName)
runnableSuite.AftrEach = RBS_CMN_GetFunction(group.afterEachFunction, group.afterEachFunctionName)
runnableSuite.AfterEach = RBS_CMN_GetFunction(group.afterEachFunction, group.afterEachFunctionName)
return runnableSuite
end function
Function ItemGenerator(scheme as object) as Object
Expand Down Expand Up @@ -2023,7 +2023,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
end if
testStatObj.Time = testTimer.TotalMilliseconds()
RBS_STATS_AppendTestStatistic(suiteStatObj, testStatObj)
if RBS_CMN_IsFunction(testCase.afterEach)
if RBS_CMN_IsFunction(testSuite.afterEach)
testSuite.afterEach()
end if
if testStatObj.Result <> "Success"
Expand Down
4 changes: 2 additions & 2 deletions source/buildinfo.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Function BuildDate()
return "Oct 1 2018 19:28:58"
return "Oct 1 2018 19:47:45"
End Function
Function BuildCommit()
return "91871e9"
return "e9f42a4"
End Function
4 changes: 2 additions & 2 deletions source/rooibos.cat.brs
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ function RBS_ItG_GetRunnableTestSuite(group) as object
runnableSuite.SetUp = RBS_CMN_GetFunction(group.setupFunction, group.setupFunctionName)
runnableSuite.TearDown = RBS_CMN_GetFunction(group.teardownFunction, group.teardownFunctionName)
runnableSuite.BeforeEach = RBS_CMN_GetFunction(group.beforeEachFunction, group.beforeEachFunctionName)
runnableSuite.AftrEach = RBS_CMN_GetFunction(group.afterEachFunction, group.afterEachFunctionName)
runnableSuite.AfterEach = RBS_CMN_GetFunction(group.afterEachFunction, group.afterEachFunctionName)
return runnableSuite
end function
Function ItemGenerator(scheme as object) as Object
Expand Down Expand Up @@ -2023,7 +2023,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
end if
testStatObj.Time = testTimer.TotalMilliseconds()
RBS_STATS_AppendTestStatistic(suiteStatObj, testStatObj)
if RBS_CMN_IsFunction(testCase.afterEach)
if RBS_CMN_IsFunction(testSuite.afterEach)
testSuite.afterEach()
end if
if testStatObj.Result <> "Success"
Expand Down
28 changes: 28 additions & 0 deletions source/tests/issue_13_afterEach_not_running.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'@TestSuite [RBSA] Rooibos before after tests

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It tests before each and after each are running
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'@BeforeEach
function RBSA__BeforeEach() as void
? "!!! Before"
end function


'@AfterEach
function RBSA__AfterEach() as void
? "!!! After"
end function

'@Test before after
function RBSA__before_after() as void

assertResult = m.Fail("reason")

isFail = m.currentResult.isFail
m.currentResult.Reset()

m.AssertFalse(assertResult)
m.AssertTrue(isFail)
end function
100 changes: 100 additions & 0 deletions source/tests/verifyBeforeEachAfterEach.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
'@TestSuite [BEAER] BeforeEach and AfterEach Running

'@Setup
function BEAER_Setup() as void
? "!!! Setup"
end function


'@TearDown
function BEAER_TearDown() as void
? "!!! TearDown"
end function

'@BeforeEach
function BEAER_BeforeEach() as void
? "!!! Before"
end function


'@AfterEach
function BEAER_AfterEach() as void
? "!!! After"
end function

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It tests group 1 - should have global before/after
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'@Test 1
function BEAER_group1_1() as void
m.AssertTrue(true)
end function

'@Test 2
function BEAER_group1_2() as void
m.AssertTrue(true)
end function

'@Test 3
'@Params["a"]
'@Params["b"]
'@Params["c"]
function BEAER_group1_3(values) as void
m.AssertTrue(true)
end function

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It tests group 2 - should have group before after
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'@BeforeEach
function BEAER_group2_BeforeEach() as void
? "!!! Before GROUP 2"
end function


'@AfterEach
function BEAER_group2_AfterEach() as void
? "!!! After GROUP 2"
end function

'@Test 1
function BEAER_group2_1() as void
m.AssertTrue(true)
end function

'@Test 2
function BEAER_group2_2() as void
m.AssertTrue(true)
end function

'@Test 3
'@Params["a"]
'@Params["b"]
'@Params["c"]
function BEAER_group2_3(values) as void
m.AssertTrue(true)
end function

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It tests group 3 - should have global before/after
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'@Test 1
function BEAER_group3_1() as void
m.AssertTrue(true)
end function

'@Test 2
function BEAER_group3_2() as void
m.AssertTrue(true)
end function

'@Test 3
'@Params["a"]
'@Params["b"]
'@Params["c"]
function BEAER_group3_3(values) as void
m.AssertTrue(true)
end function
2 changes: 1 addition & 1 deletion src/Rooibos_ItGroup.brs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function RBS_ItG_GetRunnableTestSuite(group) as object
runnableSuite.SetUp = RBS_CMN_GetFunction(group.setupFunction, group.setupFunctionName)
runnableSuite.TearDown = RBS_CMN_GetFunction(group.teardownFunction, group.teardownFunctionName)
runnableSuite.BeforeEach = RBS_CMN_GetFunction(group.beforeEachFunction, group.beforeEachFunctionName)
runnableSuite.AftrEach = RBS_CMN_GetFunction(group.afterEachFunction, group.afterEachFunctionName)
runnableSuite.AfterEach = RBS_CMN_GetFunction(group.afterEachFunction, group.afterEachFunctionName)

return runnableSuite
end function
2 changes: 1 addition & 1 deletion src/Rooibos_TestRunner.brs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
testStatObj.Time = testTimer.TotalMilliseconds()
RBS_STATS_AppendTestStatistic(suiteStatObj, testStatObj)

if RBS_CMN_IsFunction(testCase.afterEach)
if RBS_CMN_IsFunction(testSuite.afterEach)
testSuite.afterEach()
end if

Expand Down

0 comments on commit 309dbb5

Please sign in to comment.