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

Test error output in expect_message() #395

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions tests/testthat/reporters/check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@ FALSE isn't true.
stop
1: stop("stop") at reporters/tests.R:28

6. Error: Error:3 (@tests.R#36) ------------------------------------------------
!
1: f() at reporters/tests.R:36
2: g() at reporters/tests.R:32
3: h() at reporters/tests.R:33
4: stop("!") at reporters/tests.R:34

testthat results ================================================================
OK: 5 SKIPPED: 2 FAILED: 6
OK: 7 SKIPPED: 2 FAILED: 6
1. Failure: Failure:1 (@tests.R#8)
2. Failure: Failure:2a (@tests.R#12)
3. Failure: Failure:2b (@tests.R#15)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/reporters/minimal.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.FFFF.EESSWWW
.FFFF.ESSWWWF
1 change: 0 additions & 1 deletion tests/testthat/reporters/rstudio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ reporters/tests.R#12:1 [failure] Failure:2a. Failure has been forced
reporters/tests.R#15:1 [failure] Failure:2b. FALSE isn't true.
reporters/tests.R#20:1 [failure] Failure:loop. `i` not equal to 2.
reporters/tests.R#28:1 [error] Error:1. stop
reporters/tests.R#36:1 [error] Error:3. !
reporters/tests.R#42:1 [skip] Skip:1. skip
reporters/tests.R#47:1 [skip] Skip:2. skip
reporters/tests.R#53:1 [warning] Warning:1. abc
Expand Down
22 changes: 17 additions & 5 deletions tests/testthat/reporters/summary.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Expectations: .1234.
Errors: 56
Errors: 5
Skips: SS
Warnings: WWW
Promises: 7

Skipped --------------------------------------------------------------------
1. Skip:1 (@tests.R#42) - skip
Expand Down Expand Up @@ -40,9 +41,20 @@ stop

6. Error: Error:3 (@tests.R#36) ------------------------------------------------
!
1: f() at reporters/tests.R:36
2: g() at reporters/tests.R:32
3: h() at reporters/tests.R:33
4: stop("!") at reporters/tests.R:34
1: expect_message(f(), NA) at reporters/tests.R:36
2: evaluate_promise(object, capture_warnings = FALSE) at /home/muelleki/git/R/testthat/R/expect-output.R:145
3: with_sink(temp, withCallingHandlers(withVisible(code), warning = handle_warning,
message = handle_message)) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:56
4: withCallingHandlers(withVisible(code), warning = handle_warning, message = handle_message) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:87
5: withVisible(code)
6: f()
7: g() at reporters/tests.R:32
8: h() at reporters/tests.R:33
9: stop("!") at reporters/tests.R:34

7. Failure: Promises:1 (@tests.R#64) -------------------------------------------
expect_false(FALSE) produced output.
.


DONE =======================================================================
19 changes: 14 additions & 5 deletions tests/testthat/reporters/tap.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1..13
1..15
# Context Expectations
ok 1 Success
not ok 2 Failure:1
Expand All @@ -22,14 +22,23 @@ not ok 7 Error:1
1: stop("stop") at reporters/tests.R:28
not ok 8 Error:3
!
1: f() at reporters/tests.R:36
2: g() at reporters/tests.R:32
3: h() at reporters/tests.R:33
4: stop("!") at reporters/tests.R:34
1: expect_message(f(), NA) at reporters/tests.R:36
2: evaluate_promise(object, capture_warnings = FALSE) at /home/muelleki/git/R/testthat/R/expect-output.R:145
3: with_sink(temp, withCallingHandlers(withVisible(code), warning = handle_warning,
message = handle_message)) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:56
4: withCallingHandlers(withVisible(code), warning = handle_warning, message = handle_message) at /home/muelleki/git/R/testthat/R/evaluate-promise.R:87
5: withVisible(code)
6: f()
7: g() at reporters/tests.R:32
8: h() at reporters/tests.R:33
9: stop("!") at reporters/tests.R:34
# Context Skips
ok 9 # SKIP skip
ok 10 # SKIP skip
# Context Warnings
ok 11 # WARNING abc
ok 12 # WARNING def
ok 13 # WARNING ghi
# Context Promises
ok 14 Promises:1
ok 15 Promises:1
13 changes: 10 additions & 3 deletions tests/testthat/reporters/teamcity.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
##teamcity[testSuiteFinished name='Error:1']

##teamcity[testSuiteStarted name='Error:3']
##teamcity[testStarted name='expectation 1']
##teamcity[testFailed name='expectation 1' message='!' details='1: f() at reporters/tests.R:36|n2: g() at reporters/tests.R:32|n3: h() at reporters/tests.R:33|n4: stop("!") at reporters/tests.R:34']
##teamcity[testFinished name='expectation 1']
##teamcity[testSuiteFinished name='Error:3']

##teamcity[testSuiteFinished name='Errors']
Expand Down Expand Up @@ -77,3 +74,13 @@
##teamcity[testSuiteFinished name='Warnings']


##teamcity[testSuiteStarted name='Promises']
##teamcity[testSuiteStarted name='Promises:1']
##teamcity[testStarted name='expectation 2']
##teamcity[testFailed name='expectation 2' message='expect_false(FALSE) produced output.' details='##teamcity|[testStarted name=|'expectation 1|'|]\n##teamcity|[testFinished name=|'expectation 1|'|]']
##teamcity[testFinished name='expectation 2']
##teamcity[testSuiteFinished name='Promises:1']

##teamcity[testSuiteFinished name='Promises']


8 changes: 7 additions & 1 deletion tests/testthat/reporters/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test_that("Error:3", {
g <- function() {h()}
h <- function() {stop("!")}

f()
expect_message(f(), NA)
})

context("Skips")
Expand All @@ -57,3 +57,9 @@ test_that("Warning:2", {
warning("def")
warning("ghi")
})

context("Promises")

test_that("Promises:1", {
expect_output(expect_false(FALSE), NA)
})