Let's consider the test contract in which the constructor accepts two params:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;
contract Test {
address public owner;
address public user1;
address public user2;
constructor (address _user1, address _user2) {
owner = msg.sender;
user1 = _user1;
user2 = _user2;
}
}
Truffle-test will use MyContract.new([arg1, arg2, ...], [tx params]) to pass params to the constructor:
const TestContract = artifacts.require('Test');
contract('Test', function (accounts) {
const [owner, user1, user2] = accounts;
const txParams = { from: owner };
beforeEach(async function () {
this.testContract = await TestContract.new(user1, user2, txParams);
});
it('has an owner, user1 and user2', async function () {
expect(await this.testContract.owner()).to.equal(owner);
expect(await this.testContract.user1()).to.equal(user1);
expect(await this.testContract.user2()).to.equal(user2);
});
});
Take into account that to access to state-variable is used the getter-function.