-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
When multiple test files define contracts with identical names, kontrol silently ignores some tests during parsing due to contract overwriting. The affected tests are completely excluded from execution without warnings or errors.
For example, given:
- CounterFuzz.t.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Test, console} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";
contract CounterTest is Test {
Counter public counter;
function setUp() public {
counter = new Counter();
}
function testFuzz_setNumber(uint256 n) public {
counter.setNumber(n);
assertEq(counter.number(), n);
}
}
- Counter.t.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Test, console} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";
contract CounterTest is Test {
Counter public counter;
function setUp() public {
counter = new Counter();
}
function test_cast() public {
uint256 result;
int256 i = -1;
result = uint256(i);
console.log(result);
}
}
Running forge test will execute both tests:
Ran 1 tests for test/Counter.t.sol:CounterTest
[PASS] test_cast() (gas: 3250)
Suite result: FAILED. 1 passed; 0 failed; 0 skipped; finished in 468.18µs (174.72µs CPU time)
Ran 1 test for test/CounterFuzz.t.sol:CounterTest
[PASS] testFuzz_setNumber(uint256) (runs: 257, μ: 28945, ~: 29333)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.97ms (4.64ms CPU time)
And control won't identify all tests
$ kontrol prove --mt CounterTest.test
🏃 Running Kontrol proofs 🏃
Add `--verbose` to `kontrol prove` for more details!
Selected functions: test%CounterTest.testFuzz_setNumber(uint256)
Running setup functions in parallel: test%CounterTest.setUp()
$ kontrol prove --mt CounterTest.test_cast
🏃 Running Kontrol proofs 🏃
Add `--verbose` to `kontrol prove` for more details!
ValueError: Test identifiers not found: {'CounterTest.test_cast'}
Metadata
Metadata
Assignees
Labels
No labels