简体   繁体   中英

Some Truffle test not executed

It seems like some of my truffle tests are not executed. Compilation and everything is working fine. I also get no error messages what so ever.

As Im learning dapp development with a book you can download the example code right here . And here is the corresponding book.

The code that I'm referring to is in Kap12\Kap12_Security_Truffle_Project if I run truffle test only some of the tests are executed, same if I run only a specific test that wasn't executed with truffle test

So for example when I run truffle test.\test\TestReentrancy.sol the output is:

Compiling your contracts...
===========================
> Compiling .\contracts\Delegation.sol
> Compiling .\contracts\GasSiphoningWallet.sol
> Compiling .\contracts\GasToken.sol
> Compiling .\contracts\KingOfTheEther.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\Reentrancy.sol
> Compiling .\contracts\SmuggleEther.sol
> Compiling .\contracts\UnderflowToken.sol
> Compiling .\contracts\Utility.sol
> Compiling .\contracts\GasToken.sol
> Compiling .\contracts\Reentrancy.sol
> Compiling .\contracts\Utility.sol
> Compiling .\test\TestReentrancy.sol
> Artifacts written to C:\Users\KONSTA~1\AppData\Local\Temp\test--15764-W3tQRszemoJS
> Compiled successfully using:
   - solc: 0.5.0+commit.1d4f565a.Emscripten.clang



  0 passing (1ms)

Output: truffle version

Truffle v5.3.4 (core: 5.3.4)
Solidity - 0.5.0 (solc-js)
Node v14.16.1
Web3.js v1.3.5

Would be very helpful If someone else could test if the code works on his system.

Most probably you trying to deploy your smart contract like this. I am facing the same problem.

  var instance = await BrownieToken.deployed();
   
  it("Initialize contract with correct value", async ()=> {
    const tokenName = await instance.name();
    const tokenSymbol = await instance.symbol()
    assert.equal(tokenName, "BrownieToken","Token name should be BrownieToken");
    assert.equal(tokenSymbol, "BT","Token symbol should be BT");
    
  });

Wrap your deployment part in before. It's work for me hopes its works for u as well;)

var instance;
before(async() => {
  instance = await BrownieToken.deployed();
}) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM