From faf6b063d61bf0b57c6d0102e43ce0e82435d72a Mon Sep 17 00:00:00 2001 From: Jakub Sobolewski Date: Tue, 19 Nov 2024 21:37:59 +0100 Subject: [PATCH 1/2] update test template for use_test --- inst/templates/test-example-2.1.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/inst/templates/test-example-2.1.R b/inst/templates/test-example-2.1.R index 8849056e2..dd307df7d 100644 --- a/inst/templates/test-example-2.1.R +++ b/inst/templates/test-example-2.1.R @@ -1,3 +1,10 @@ -test_that("multiplication works", { - expect_equal(2 * 2, 4) +test_that("is.numeric returns TRUE if all elements of a vector are integers", { + # Arrange + x <- c(1L, 2L, 3L) + + # Act + result <- is.numeric(x) + + # Assert + expect_true(result) }) From 88346140166b82630a9a0bf6e27a16c34796bfa5 Mon Sep 17 00:00:00 2001 From: Jakub Sobolewski Date: Tue, 19 Nov 2024 21:46:50 +0100 Subject: [PATCH 2/2] update NEWS --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index b1c58551b..95daa0bc5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # usethis (development version) +* `use_test()` now creates a unit test with the ['#Arrange, #Act, #Assert'](https://xp123.com/3a-arrange-act-assert/) pattern. * `use_tidy_upkeep_issue()` now records the year it is being run in the `Config/usethis/upkeep` field in DESCRIPTION. If this value exists it is furthermore used to filter the checklist when making the issue.