You should be able to specify the order in which tests are run. Right now tests are run in alphabetical order. Since some contracts might depend on other contracts working it is confusing if the dependant contract runs first. Therefore it would be nice to be able to specify the order in a config file.
Thanks @oed
Since some contracts might depend on other contracts working it is confusing if the dependant contract runs first
Your test files shouldn’t be dependent on each other. Your contracts can be, but your test files shouldn’t. That said, every test file has access to all contracts, and every test file gets contracts redeployed before the tests in the file run. So as far as running is concerned, order of test files shouldn’t matter. Order of _tests_ on the other hand (it “…”) are run in the order they’re listed in the test file, I believe.
Why has this been closed on the answer 'tests shouldn't rely on each other?' this is not a fix to the issue.
This is not true that the contracts are redeployed in between tests as I have 4 test files which run through 4 different test cases of an ICO, my first file is a successful run, my second is an unsuccessful which instantly fails as my ICO is now finished from the previous file.
I have tried to create a new sale however get an 'invalid opcode' error which I have debugged down to an issue with the start time, which is very strange as its simply just a time stamp - seems to only work if I set the start date to deploy a new sale one month or more in the future.
What my tests DO DEPEND ON is the current time on the dev blockchain, as my ICO goes through tests I must 'time travel' to the next stage.
So following on from this,
I now have to make sure my start time is appropriate to the time of the blockchain...
How can I do that without being reliant on what order my test files are executed?
This is not a fix and shouldn't have been closed, there will always be cases for ordering tests.
yes I have hit the same issue. To test the time-dependent functionality of my smart contracts I have time-travelled the testnet which then causes many of the subsequent tests to fail. I need the time travelled tests to run last.
Most helpful comment
Why has this been closed on the answer 'tests shouldn't rely on each other?' this is not a fix to the issue.
This is not true that the contracts are redeployed in between tests as I have 4 test files which run through 4 different test cases of an ICO, my first file is a successful run, my second is an unsuccessful which instantly fails as my ICO is now finished from the previous file.
I have tried to create a new sale however get an 'invalid opcode' error which I have debugged down to an issue with the start time, which is very strange as its simply just a time stamp - seems to only work if I set the start date to deploy a new sale one month or more in the future.
What my tests DO DEPEND ON is the current time on the dev blockchain, as my ICO goes through tests I must 'time travel' to the next stage.
So following on from this,
I now have to make sure my start time is appropriate to the time of the blockchain...
How can I do that without being reliant on what order my test files are executed?
This is not a fix and shouldn't have been closed, there will always be cases for ordering tests.