forked from r-lib/testthat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated source code from rlib/testthat/main (#5)
Give test_dir() a recursive option (r-lib#1605) The recursive argument allows test files in nested directories.
- Loading branch information
Showing
15 changed files
with
118 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: testthat | ||
Title: Unit Testing for R | ||
Version: 3.1.10.9000 | ||
Version: 3.1.10.9001 | ||
Authors@R: c( | ||
person("Hadley", "Wickham", , "[email protected]", role = c("aut", "cre")), | ||
person("Posit Software, PBC", role = c("cph", "fnd")), | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
hello <- function() "Hello World" |
22 changes: 22 additions & 0 deletions
22
tests/testthat/test_dir_recursive/nested_folder/test-errors.R
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
test_that("simple", { | ||
stop("argh") | ||
}) | ||
|
||
test_that("after one success", { | ||
expect_true(TRUE) | ||
stop("argh") | ||
expect_true(TRUE) | ||
}) | ||
|
||
test_that("after one failure", { | ||
expect_true(FALSE) | ||
stop("argh") | ||
}) | ||
|
||
test_that("in the test", { | ||
expect_true(stop("Argh")) | ||
}) | ||
|
||
test_that("in expect_error", { | ||
expect_error(stop("Argh")) | ||
}) |
13 changes: 13 additions & 0 deletions
13
tests/testthat/test_dir_recursive/nested_folder/test-failures.R
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
test_that("just one failure", { | ||
expect_true(FALSE) | ||
}) | ||
|
||
test_that("one failure on two", { | ||
expect_false(FALSE) | ||
expect_true(FALSE) | ||
}) | ||
|
||
test_that("no failure", { | ||
expect_false(FALSE) | ||
expect_true(TRUE) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test_that("Skips skip", { | ||
skip("Skipping to avoid certain failure") | ||
expect_true(FALSE) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
expect_equal(2, 2) |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
test_that("logical tests act as expected", { | ||
expect_true(TRUE) | ||
expect_false(FALSE) | ||
}) | ||
|
||
test_that("logical tests ignore attributes", { | ||
expect_true(c(a = TRUE)) | ||
expect_false(c(a = FALSE)) | ||
}) | ||
|
||
test_that("equality holds", { | ||
expect_equal(5, 5) | ||
expect_identical(10, 10) | ||
}) | ||
|
||
test_that("can't access variables from other tests 2", { | ||
a <- 10 | ||
}) | ||
|
||
test_that("can't access variables from other tests 1", { | ||
expect_false(exists("a")) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test_that("empty test", NULL) | ||
|
||
test_that("empty test with error", stop("Argh")) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# test that the companion helper script is sourced by test_dir | ||
test_that("helper test", { | ||
expect_equal(hello(), "Hello World") | ||
}) |