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/:
- Create a
test-foo.R
a <- 1
expect_equal(foo(a), 1)
All the test pass!
- Create
helper-foo.R
The "test" helper-foo.R is runned reporting no test and no erorr :-)
- Remove assignment from
test-foo.R which becomes simply
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
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
The "test" helper-foo.R is run reporting no test and no errors
- Modify
test-foo.R accordingly
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.
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.RinR/:test-foo.RAll the test pass!
helper-foo.RThe "test"
helper-foo.Ris runned reporting no test and no erorr :-)test-foo.Rwhich 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.RThe "test"
helper-foo.Ris run reporting no test and no errorstest-foo.RaccordinglyAnd the test is run reporting an error:
Adopting a solution like the one purposed in #376 could help.