Using several it blocks is exactly what you need in the given scenario.
If I understand correctly, then your testing document should look like something like this:
contract('amm', (accounts) =>{
var tokenInstance;
it('adds the funds', ()=> {
return AMMToken.deployed().then((instance)=> {
tokenInstance = instance;
return tokenInstance.addFund(12);
}).then((addFundReceipt)=> {
assert.equal(addFundReceipt.success, true, 'fund added correctly');
});
});
it('performs the swap',()=> {
return AMMToken.deployed().then((instance)=> {
tokenInstance = instance;
return tokenInstance.swap(to,from);
}).then((SwapFundReceipt)=>{
assert.equal(SwapFundReceipt.success, true, 'fund added correctly');
});
});
Using the above structure, in every call, you can set your Arrange and Act by calling tokenInstance.callYourFunction(ARRANGED values) and Assert in the succeeding promise.
Since truffle comes with Chai Assertion Library, its very intuitive to use it. Also, if there are other steps that need to be performed before adding your funds like validating if funds are available, then you can test them all before calling. Since your Assert statements have a statement to go with it, if any of the assertions fail, you will see exactly what failed, this solves the problem of your block being "non-informative".
I personally have never got over promises. I keep coming back to it when writing tests.
it
blocks because one steps depends on previous one" - you actually can, as long as there is nobeforeEach
clause at the beginning.