简体   繁体   English

一些 Truffle 测试未执行

[英]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 .当我通过一本书学习 dapp 开发时,您可以在此处下载示例代码。 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我指的代码在Kap12\Kap12_Security_Truffle_Project如果我运行 truffle truffle test只执行一些测试,如果我只运行一个没有用truffle test执行的特定测试

So for example when I run truffle test.\test\TestReentrancy.sol the output is:因此,例如,当我运行truffle test.\test\TestReentrancy.sol时,output 是:

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 Output:松露版

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();
}) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有“It”语句的松露测试错误 - an error in truffle test with "It" statement 松露编译,松露测试或松露迁移不会显示任何控制台输出或异常。 它什么也没做 - truffle compile , truffle test or truffle migration does not show any console output or exception . It just do nothing 设置--network标志时,松露测试失败 - truffle test fail when --network flag is set 如何发送wei/eth到合约地址? (使用松露 javascript 测试) - How to send wei/eth to contract address? (using truffle javascript test) 'transaction: out of gas' 松露测试时,设置映射键值错误 - 'transaction: out of gas' when truffle test, set mapping key value error 松露配置 - Truffle configuration 如何解决以下错误:错误:找不到模块“@openzeppelin/test-helpers”(在 VSCode 终端中输入“truffle test”时) - How do you resolve the following error: Error: Cannot find module '@openzeppelin/test-helpers' (when typing 'truffle test' in VSCode terminal) 我的测试遇到了错误,我已经编译并迁移了。 我运行了“松露测试”,但出现了这个错误 - I have run into an error with my testing, i have compiled and migrated . i ran 'truffle test' and i have this error 松露安装问题“ -bash:松露:找不到命令” - truffle installation issue “-bash : truffle: command not found” 区块链松露迁移错误 - Blockchain truffle Migration Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM