You are right.
new are from truffle-contract. If you look at the doc:
deployed(): Create an instance of MyContract that represents the
default address managed by MyContract.
new(): Deploy a new version of this contract to the network, getting an instance > of MyContract that represents the newly deployed instance.
AFAIK, when you run
truffle test, initially it will go through your migration script, and migrate new contracts onto the node you have specified in
truffle.js. When you get a instance from
On the other hand, when you get a instance from
So, if your contract has states, and the results of tests are dependent on the sequence they are run, then you'll need to use
new() in beforeEach to get a clean room environment for individual tests.
Note that if you use
contract() function, then before each contract() function is run, your contracts are redeployed to the running Ethereum client so the tests within it run with a clean contract state.