Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
b52433aa
Commit
b52433aa
authored
Apr 13, 2021
by
aniket-engg
Committed by
Aniket
Apr 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generated test file updated
parent
a48cf8d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
testTab.js
apps/remix-ide/src/app/tabs/testTab/testTab.js
+15
-10
No files found.
apps/remix-ide/src/app/tabs/testTab/testTab.js
View file @
b52433aa
...
...
@@ -67,11 +67,17 @@ class TestTabLogic {
generateTestContractSample
(
hasCurrent
,
fileToImport
,
contractName
=
'testSuite'
)
{
let
relative
=
remixPath
.
relative
(
this
.
currentPath
,
remixPath
.
dirname
(
fileToImport
))
if
(
relative
===
''
)
relative
=
'.'
const
comment
=
hasCurrent
?
`import "
${
relative
}
/
${
remixPath
.
basename
(
fileToImport
)}
";`
:
'//
Import here the file to test.
'
const
comment
=
hasCurrent
?
`import "
${
relative
}
/
${
remixPath
.
basename
(
fileToImport
)}
";`
:
'//
<import file to test>
'
return
`// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
import "remix_tests.sol"; // this import is automatically injected by Remix.
// This import is automatically injected by Remix
import "remix_tests.sol";
// This import is required to use custom transaction context
// Although it may fail compilation in 'Solidity Compiler' plugin
// But it will work fine in 'Solidity Unit Testing' plugin
import "remix_accounts.sol";
${
comment
}
...
...
@@ -81,15 +87,15 @@ contract ${contractName} {
/// 'beforeAll' runs before all other tests
/// More special functions are: 'beforeEach', 'beforeAll', 'afterEach' & 'afterAll'
function beforeAll() public {
//
Here should instantiate tested contract
//
<instantiate contract>
Assert.equal(uint(1), uint(1), "1 should be equal to 1");
}
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");
// Use 'Assert'
methods: https://remix-ide.readthedocs.io/en/latest/assert_library.html
Assert.ok(2 == 2, 'should be true');
Assert.
greaterThan(uint(2), uint(1), "2 should be greater than to 1
");
Assert.
lesserThan(uint(2), uint(3), "2 should be lesser than
to 3");
}
function checkSuccess2() public pure returns (bool) {
...
...
@@ -98,11 +104,10 @@ contract ${contractName} {
}
function checkFailure() public {
Assert.
equal(uint(1), uint(2), "1 is not equal to 2
");
Assert.
notEqual(uint(1), uint(1), "1 should not be equal to 1
");
}
/// Custom Transaction Context
/// See more: https://remix-ide.readthedocs.io/en/latest/unittesting.html#customization
/// Custom Transaction Context: https://remix-ide.readthedocs.io/en/latest/unittesting.html#customization
/// #sender: account-1
/// #value: 100
function checkSenderAndValue() public payable {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment