In openzeppelin-eth/tests, many tests uses a constructor to instantiate the contracts under test.
Instead of
const contract = new Contract();
contract.initialize()
they just use a contract, that overrides the original contract and call the initializer-functions directly into the constructor function, where all required arguments are passed.
I don’t know, why the tests in openzepplin are running through because I ran into issues using the same pattern.
import “…/MintedTokenSale.sol”;
contract MintedTokenSaleImpl is MintedTokenSale {
constructor(uint256 openingTime, uint256 closingTime, MyToken token) public {
super.initialize(openingTime, closingTime, token);
}
}
will not work. It reverts using
const c = new MintedTokenSaleImpl(openingTime, closingTime, token);