You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you modify a script, all tests (and helpers) are run.
If you modify a test, only that test is run, correctly.
The problem rises if you create a helper file to extract some preprocessing from a test.
When you create the helper it is run, it contains no test, and the results are all green zeros, correctly. Next, when you return to the test function, and you remove the no more necessary code, only this test is run, but not the helper, and it rises a (wrong) error.
On the other hand, the first script you modify later provide a run of the whole test folder, helper included, and from that time on the objects are stored in the test environment, and so everything return working. The problem occurs only the first time.
example:
Create foo.R in R/:
foo <- function(x) x
Create a test-foo.R
a <- 1
expect_equal(foo(a), 1)
All the test pass!
Create helper-foo.R
a <- 1
The "test" helper-foo.R is runned reporting no test and no erorr :-)
Remove assignment from test-foo.R which becomes simply
expect_equal(foo(a), 1)
And now the test report an error
object 'a' not found
Make any modification to any script, for example, add curly braces to foo.R, just to save it and trig the call to the tests
foo <- function(x) {
x
}
And everything is evaluated, and all the test passed.
Even if you modify test-foo.R, e.g.
expect_equal(foo(a), 1)
expect_equal(foo(a), 1)
And only this test is called and run, from now it passes correctly. Until you change the helper:
Modify helper-foo.R
a <- 2
The "test" helper-foo.R is run reporting no test and no errors
Modify test-foo.R accordingly
expect_equal(foo(a), 2)
And the test is run reporting an error:
'a' not equal to 2
1/1 mismatches
[1] 1 - 2 == -1"
Adopting a solution like the one purposed in #376 could help.
The text was updated successfully, but these errors were encountered:
If you modify a script, all tests (and helpers) are run.
If you modify a test, only that test is run, correctly.
The problem rises if you create a helper file to extract some preprocessing from a test.
When you create the helper it is run, it contains no test, and the results are all green zeros, correctly. Next, when you return to the test function, and you remove the no more necessary code, only this test is run, but not the helper, and it rises a (wrong) error.
On the other hand, the first script you modify later provide a run of the whole test folder, helper included, and from that time on the objects are stored in the test environment, and so everything return working. The problem occurs only the first time.
example:
foo.R
inR/
:test-foo.R
All the test pass!
helper-foo.R
The "test"
helper-foo.R
is runned reporting no test and no erorr :-)test-foo.R
which becomes simplyAnd now the test report an error
foo.R
, just to save it and trig the call to the testsAnd everything is evaluated, and all the test passed.
test-foo.R
, e.g.And only this test is called and run, from now it passes correctly. Until you change the helper:
helper-foo.R
The "test"
helper-foo.R
is run reporting no test and no errorstest-foo.R
accordinglyAnd the test is run reporting an error:
Adopting a solution like the one purposed in #376 could help.
The text was updated successfully, but these errors were encountered: