I am assuming that the issue is that you are always using the .call()method.
This method will, in fact, execute the code but will not save to the blockchain.
You should use the .call() method, only when reading from the blockchain or testing for throws.
Just remove the .call() in the adding function and it should work.
var Adder = artifacts.require("./Adder.sol");
contract('Adder', accounts => {
it("should start with 0", () =>
Adder.deployed()
.then(instance => instance.getTotal.call())
.then(total => assert.equal(total.toNumber(), 0))
);
it("should increase the total as amounts are added", () =>
Adder.deployed()
.then(instance => instance.add(10)
.then(() => instance.getTotal.call())
.then(total => assert.equal(total.toNumber(), 10))
)
);
});
Also, consider declaring the instance variable outside the chain of functions of the promise since the context is not shared. Consider using async/await for tests instead of promises.
var Adder = artifacts.require("./Adder.sol");
contract('Adder', accounts => {
it("should start with 0", async () => {
let instance = await Adder.deployed();
assert.equal((await instance.getTotal.call()).toNumber(), 0);
});
it("should increase the total as amounts are added", async () => {
let instance = await Adder.deployed();
await instance.add(10);
assert.equal((await instance.getTotal.call()).toNumber(), 10);
});
});