From 7173f83f61c73b6a5572434a5d670437af6e7947 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 13 Apr 2020 20:43:18 +0530 Subject: [PATCH 1/2] one contract removed & indentation fixed --- src/app/tabs/testTab/testTab.js | 54 +++++++++++---------------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/src/app/tabs/testTab/testTab.js b/src/app/tabs/testTab/testTab.js index 715a239c4a..7a9d5b920d 100644 --- a/src/app/tabs/testTab/testTab.js +++ b/src/app/tabs/testTab/testTab.js @@ -38,46 +38,28 @@ class TestTabLogic { generateTestContractSample () { return `pragma solidity >=0.4.0 <0.7.0; - import "remix_tests.sol"; // this import is automatically injected by Remix. +import "remix_tests.sol"; // this import is automatically injected by Remix. - // file name has to end with '_test.sol' - contract test_1 { +// file name has to end with '_test.sol' +contract test_1 { - function beforeAll() public { - // here should instantiate tested contract - Assert.equal(uint(4), uint(3), "error in before all function"); - } - - function check1() public { - // use 'Assert' to test the contract - Assert.equal(uint(2), uint(1), "error message"); - Assert.equal(uint(2), uint(2), "error message"); - } - - function check2() public view returns (bool) { - // use the return value (true or false) to test the contract - return true; - } - } - - contract test_2 { - - function beforeAll() public { - // here should instantiate tested contract - Assert.equal(uint(4), uint(3), "error in before all function"); - } + function beforeAll() public { + // here should instantiate tested contract + Assert.equal(uint(4), uint(3), "error in before all function"); + } - function check1() public { - // use 'Assert' to test the contract - Assert.equal(uint(2), uint(1), "error message"); - Assert.equal(uint(2), uint(2), "error message"); - } + function check1() public { + // use 'Assert' to test the contract + Assert.equal(uint(2), uint(1), "error message"); + Assert.equal(uint(2), uint(2), "error message"); + } - function check2() public view returns (bool) { - // use the return value (true or false) to test the contract - return true; - } - }` + function check2() public view returns (bool) { + // use the return value (true or false) to test the contract + return true; + } +} +` } } From 6bafcf9dcb8b5ad8e06007bd79508bf3f16e4713 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 13 Apr 2020 21:20:44 +0530 Subject: [PATCH 2/2] tests in test file updated --- src/app/tabs/testTab/testTab.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/app/tabs/testTab/testTab.js b/src/app/tabs/testTab/testTab.js index 7a9d5b920d..b244875b57 100644 --- a/src/app/tabs/testTab/testTab.js +++ b/src/app/tabs/testTab/testTab.js @@ -43,21 +43,28 @@ import "remix_tests.sol"; // this import is automatically injected by Remix. // file name has to end with '_test.sol' contract test_1 { - function beforeAll() public { - // here should instantiate tested contract - Assert.equal(uint(4), uint(3), "error in before all function"); - } + /// 'beforeAll' runs before all other tests + /// More special functions are: 'beforeEach', 'beforeAll', 'afterEach' & 'afterAll' + function beforeAll() public { + // Here should instantiate tested contract + Assert.equal(uint(1), uint(1), "1 should be equal to 1"); + } - function check1() public { - // use 'Assert' to test the contract - Assert.equal(uint(2), uint(1), "error message"); - Assert.equal(uint(2), uint(2), "error message"); - } + function checkSuccess() public { + // Use 'Assert' to test the contract, + // See documentation: https://remix-ide.readthedocs.io/en/latest/assert_library.html + Assert.equal(uint(2), uint(2), "2 should be equal to 2"); + Assert.notEqual(uint(2), uint(3), "2 should not be equal to 3"); + } - function check2() public view returns (bool) { - // use the return value (true or false) to test the contract - return true; - } + function checkSuccess2() public view returns (bool) { + // Use the return value (true or false) to test the contract + return true; + } + + function checkFailure() public { + Assert.equal(uint(1), uint(2), "1 is not equal to 2"); + } } ` }