Solidity unit test plugin browser tests

pull/5370/head
ioedeveloper 5 years ago committed by Aniket
parent a2236963ab
commit 94adcb926d
  1. 2
      package.json
  2. 2
      src/app/tabs/test-tab.js
  3. 83
      test-browser/tests/solidityUnittests.js

@ -173,7 +173,7 @@
"nightwatch_local_staticAnalysis": "nightwatch ./test-browser/tests/staticAnalysis.js --config nightwatch.js --env chrome ",
"nightwatch_local_signingMessage": "nightwatch ./test-browser/tests/signingMessage.js --config nightwatch.js --env chrome ",
"nightwatch_local_specialFunctions": "nightwatch ./test-browser/tests/specialFunctions.js --config nightwatch.js --env chrome ",
"nightwatch_local_solidityUnittests": "nightwatch ./test-browser/tests/solidityUnittests.js --config nightwatch.js --env chrome ",
"nightwatch_local_solidityUnitTests": "nightwatch ./test-browser/tests/solidityUnittests.js --config nightwatch.js --env chrome ",
"nightwatch_local_remixd": "nightwatch ./test-browser/tests/remixd.js --config nightwatch.js --env chrome ",
"nightwatch_local_terminal": "nightwatch ./test-browser/tests/terminal.js --config nightwatch.js --env chrome ",
"nightwatch_local_gist": "nightwatch ./test-browser/tests/gist.js --config nightwatch.js --env chrome ",

@ -225,7 +225,7 @@ module.exports = class TestTab extends ViewPlugin {
}
updateGenerateFileAction (currentFile) {
let el = yo`<button class="${css.generateTestFile} btn btn-primary" onclick="${this.testTabLogic.generateTestFile.bind(this.testTabLogic)}">Generate test file</button>`
let el = yo`<button class="${css.generateTestFile} btn btn-primary" data-id="testTabGenerateTestFile" onclick="${this.testTabLogic.generateTestFile.bind(this.testTabLogic)}">Generate test file</button>`
if (!currentFile) {
el.setAttribute('disabled', 'disabled')
el.setAttribute('title', 'No file selected')

@ -2,26 +2,51 @@
var init = require('../helpers/init')
var sauce = require('./sauce')
var sources = []
module.exports = {
before: function (browser, done) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Should launch solidity unit test plugin': function (browser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.clickLaunchIcon('fileExplorers')
.addFile('simple_storage.sol', sources[0]['browser/simple_storage.sol'])
.clickLaunchIcon('pluginManager')
.scrollAndClick('*[data-id="pluginManagerComponentActivateButtonsolidityUnitTesting"]')
.click('*[data-id="verticalIconsKindsolidityUnitTesting"]')
.waitForElementPresent('*[data-id="sidePanelSwapitTitle"]')
.assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'SOLIDITY UNIT TESTING')
},
'Should generate test file': function (browser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.clickLaunchIcon('fileExplorers')
.switchFile('browser/simple_storage.sol')
.click('*[data-id="verticalIconsKindsolidityUnitTesting"]')
.waitForElementPresent('*[data-id="testTabGenerateTestFile"]')
.click('*[data-id="testTabGenerateTestFile"]')
.waitForElementPresent('*[title="browser/test_test.sol"]')
},
'Should run unit test for simple_storage.sol file': function (browser) {
browser.pause(100000)
},
'Solidity Unittests': function (browser) {
runTests(browser)
},
tearDown: sauce
}
function runTests (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.click('#icon-panel div[plugin="pluginManager"]')
.scrollAndClick('#pluginManager article[id="remixPluginManagerListItem_solidityUnitTesting"] button')
.clickLaunchIcon('fileExplorers')
.switchFile('browser/3_Ballot.sol')
.clickLaunchIcon('solidityUnitTesting')
@ -34,3 +59,53 @@ function runTests (browser) {
.assert.containsText('#solidityUnittestsOutput', '✓ (Check winnin proposal with return value)')
.end()
}
var sources = [
{
'browser/simple_storage.sol': {
content: `
pragma solidity >=0.4.22 <0.7.0;
contract SimpleStorage {
uint public storedData;
constructor() public {
storedData = 100;
}
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint retVal) {
return storedData;
}
}
`
},
'browser/simple_storage_test.sol': {
content: `
pragma solidity >=0.4.22 <0.7.0;
import "remix_tests.sol";
import "./simple_storage.sol";
contract MyTest {
SimpleStorage foo;
function beforeEach() public {
foo = new SimpleStorage();
}
function initialValueShouldBe100() public returns (bool) {
return Assert.equal(foo.get(), 100, "initial value is not correct");
}
function valueIsSet200() public returns (bool) {
foo.set(200);
return Assert.equal(foo.get(), 200, "value is not 200");
}
}
`
}
}
]

Loading…
Cancel
Save