I am trying to write a unit test for my token contract whose constructor takes 6 arguments. I have written the test but each time I try to test any function on the token contract it throws TypeError saying "Member "[functionName]" not found or not visible after argument-dependent lookup in type".
Here's the unit test code
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
// 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";
import "./Bet.sol";
contract testSuite is Bet{
constructor() Bet(TestsAccounts.getAccount(0), TestsAccounts.getAccount(0), TestsAccounts.getAccount(0), TestsAccounts.getAccount(0), TestsAccounts.getAccount(0), TestsAccounts.getAccount(0)) payable {
}
/// 'beforeAll' runs before all other tests
/// More special functions are: 'beforeEach', 'beforeAll', 'afterEach' & 'afterAll'
function beforeAll() public {
Assert.equal(testSuite.totalSupply(), 250000000 * 10 ** 8, "Total supply should be 250
million");
}
}
Please, any help on how I can resolve this?
Best Answer
Proper approach to the unit testing is test contract with external calls, in this way you can see the call parameters and return values then decide what structure you should be using. If you want to test internal/private functions, make them public just for unit testing, after verifying your code make them internal/private. I think you'll create confusion for yourself when inheriting your tester code from your tested code, it'll be hard to maintain in future. I'm not speaking just for Solidity, but this holds for other languages too.
I have tried to recreate your scenario below
The tester contract is: