Movatterモバイル変換


[0]ホーム

URL:


testthat 3.3.1

testthat 3.3.0

Lifecycle changes

Expectations and tests

Other new features

Minor improvements and bugfixes

testthat 3.2.3

testthat 3.2.2

New expectations

Bug fixes and minorimprovements

testthat 3.2.1

testthat 3.2.0

Lifecycle changes

New features

Minor features and bug fixes

testthat 3.1.10

testthat 3.1.9

testthat 3.1.8

testthat 3.1.7

testthat 3.1.6

testthat 3.1.5

testthat 3.1.4

testthat 3.1.3

testthat 3.1.2

testthat 3.1.1

testthat 3.1.0

Snapshot tests

Breaking changes

Minor improvements and bugfixes

testthat 3.0.4

testthat 3.0.3

testthat 3.0.2

testthat 3.0.1

testthat 3.0.0

3rd edition

testhat 3.0.0 brings with it a 3rd edition that makes a number ofbreaking changes in order to clean up the interface and help you use ourlatest recommendations. To opt-in to the 3rd edition for your package,setConfig/testthat/edition: 3 in yourDESCRIPTION or uselocal_edition(3) inindividual tests. You can retrieve the active edition withedition_get(). Learn more invignette("third-edition").

Snapshot testing

New family of snapshot expectations (expect_snapshot(),expect_snapshot_output(),expect_snapshot_error(), andexpect_snapshot_value()) provide “snapshot” tests, wherethe expected results are stored in separate files intest/testthat/_snaps. They’re useful whenever it’s painfulto store expected results directly in the test files.

expect_snapshot_file() along withsnapshot_review() help snapshot more complex data, withinitial support for text files, images, and data frames (#1050).

Seevignette("snapshotting") for more details.

Reporters

Fixtures

Skips

Test running

Minor improvements and bugfixes

testthat 2.3.2

testthat 2.3.1

testthat 2.3.0

Conditions

This release mostly focusses on an overhaul of how testthat workswith conditions (i.e. errors, warnings and messages). There arerelatively few user-facing changes, although you should now see moreinformative backtraces from errors and failures.

Expectations

Other minor improvementsand bug fixes

testthat 2.2.1

testthat 2.2.0

New features

Minor improvements and bugfixes

testthat 2.1.1

testthat 2.1.0

New expectations

Improvements to existingexpectations

Reporters

Skips

Other new features

Other minorimprovements and bug fixes

testthat 2.0.1

testthat 2.0.0

Breaking API changes

Expectations

New and improvedexpectations

New and improved skips

Known good values

We have identified a useful family of expectations that compares theresults of an expression to a known good value stored in a file. Theyare designed to be use in conjunction with git so that you can see whatprecisely has changed, and revert it if needed.

Quasiquotation support

All expectations can now use unquoting (#626). This makes it mucheasier to generate informative failure messages when running tests in afor loop.

For example take this test:

f<-function(i)if (i>3) i*9else i*10for (iin1:5) {expect_equal(f(i), i*10)}

When it fails, you’ll see the messageError: `f(i)` not equal to `i * 10`. That’s hard todiagnose because you don’t know which iteration caused the problem!

for (iin1:5) {expect_equal(f(!!i),!!(i*10))}

If you unquote the values using!!, you get the failuremessage`f(4L)` not equal to 40.. This is much easier todiagnose! See?quasi_label() for more details.

(Note that this is not tidy evaluation per se, but is closelyrelated. At this time you can not unquote quosures.)

New features

Setup and teardown

Other new features

New default reporter

A new default reporter,ReporterProgress, produces moreaesthetically pleasing output and makes the most important informationavailable upfront (#529). You can return to the previous default bysettingoptions(testthat.default_reporter = "summary").

Reporters

Deprecated functions

Minor improvements and bugfixes

testthat 1.0.2

testthat 1.0.1

testthat 1.0.0

Breaking changes

Theexpectation() function now expects an expectationtype (one of “success”, “failure”, “error”, “skip”, “warning”) as firstargument. If you’re creating your own expectations, you’ll need to useexpect() instead (#437).

New expectations

The expectation system got a thorough overhaul (#217). This primarilymakes it easier to add new expectations in the future, but also includeda thorough review of the documentation, ensuring that relatedexpectations are documented together, and have evocative names.

One useful change is that most expectations invisibly return theinputobject. This makes it possible to chain togetherexpectations with magrittr:

factor("a")%>%expect_type("integer")%>%expect_s3_class("factor")%>%expect_length(1)

(And to make this style even easier, testthat now re-exports thepipe, #412).

The exception to this rule are the expectations that evaluate (i.e.for messages, warnings, errors, output etc), which invisibly returnNULL. These functions are now more consistent: usingNA will cause a failure if there is aerrors/warnings/messages/output (i.e. they’re not missing), and willNULL fail if there aren’t anyerrors/warnings/messages/output. This previously didn’t work forexpect_output() (#323), and the error messages wereconfusing withexpect_error(..., NA) (#342,@nealrichardson +@krlmlr, #317).

Another change is thatexpect_output() now requires youto explicitly print the output if you want to test a print method:expect_output("a", "a") will fail,expect_output(print("a"), "a") will succeed.

There are six new expectations:

A number of older features have been deprecated:

Expectations are conditions

Now all expectations are also conditions, and R’s condition system isused to signal failures and successes (#360,@krlmlr). All known conditions (currently,“error”, “warning”, “message”, “failure”, and “success”) are convertedto expectations using the newas.expectation(). This allowsthird-party test packages (such asassertthat,testit,ensurer,checkmate,assertive) to seamlessly establishtestthatcompatibility by issuing custom error conditions (e.g.,structure(list(message = "Error message"), class = c("customError", "error", "condition")))and then implementingas.expectation.customError(). Theassertthat package contains an example.

Reporters

The reporters system class has been considerably refactored to makeexisting reporters simpler and to make it easier to write new reporters.There are two main changes:

Other

testthat 0.11.0

testthat 0.10.0

testthat 0.9.1

testthat 0.9

New features

Minor improvements and bugfixes

Deprecated functions

testthat 0.8.1

testthat 0.8

testthat 0.8 comes with a new recommended structure for storing yourtests. To better meet CRAN recommended practices, testthat now recommendthat you to put your tests intests/testthat, instead ofinst/tests (this makes it possible for users to choosewhether or not to install tests). With this new structure, you’ll needto usetest_check() instead oftest_packages()in the test file (usuallytests/testthat.R) that runs alltestthat unit tests.

The other big improvement to usability comes from@kforner, who contributedcode to allow the default results (i.e. those produced bySummaryReporter) to include source references so you cansee exactly where failures occurred.

New reporters

New expectations

Minor improvements and bugfixes

testthat 0.7.1

testthat 0.7

testthat 0.6

testthat 0.5

testthat 0.4

testthat 0.3

testthat 0.2


[8]ページ先頭

©2009-2025 Movatter.jp