Files imported from the test directory cannot find already generated artifacts
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
Whenever there is a file imported into a test file when running truffle test
, and the contract object itself doesn’t match the file name, truffle complains that it cannot find the artifacts.
Steps to Reproduce
Take your standard owned contract:
pragma solidity ^0.4.16;
contract owned {
function owned() public { owner = msg.sender; }
address owner;
// This contract only defines a modifier but does not use
// it - it will be used in derived contracts.
// The function body is inserted where the special symbol
// "_;" in the definition of a modifier appears.
// This means that if the owner calls this function, the
// function is executed and otherwise, an exception is
// thrown.
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function changeOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
}
- put it into the contracts directory under the filename “Utils.sol”.
- use it in a contract (inherit the owned principle into some Widget contract).
- create a TestWidget.sol contract in the test directory. Import the Widget contract.
- Try to run
truffle test
Expected Behavior
It should be able to find it based on the artifacts in the build directory by scanning through each of the artifacts and looking to the sourcePath key in all of the artifacts to see if it matches…or it could just recompile. Whichever you think works best given the project needs.
Actual Results
1) TestRoleManager "before all" hook: prepare suite:
Error: Could not find artifacts for /Users/vor0220/itpeople/fit-repo-bitbucket/contracts/Utils.sol from any sources
Environment
- Operating System: OS X High Sierra 10.13.1
- Truffle version: v4.0.1
- Ethereum client: Ganache I suppose?
- node version: v8.0.0
- npm version: 5.5.1
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Change pytest working directory to test case directory
Good point. The problem is the artifacts aren't generated by the test methods directly. They're generated by test framework libraries, log files ......
Read more >Prepare for testing | IntelliJ IDEA Documentation - JetBrains
From the main menu, select File | Project Structure ( Ctrl+Alt+Shift+S ) or click the Project Structure button · Under Project Settings, select ......
Read more >Unit test reports - GitLab Docs
If the tests fail, the pipeline fails and users get notified. ... If JUnit report format XML files are generated and uploaded as...
Read more >Testing in Java & JVM projects - Gradle User Manual
When you're using a JVM language plugin — such as the Java Plugin — you will automatically get the following: A dedicated test...
Read more >Making a Python Package
A package usually corresponds to a directory with a file in it called __init__.py and any number ... To get submodules, you need...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This truffle framework is total bullshit, with release 4.1.5 it is not possible to even apply the tutorials correctly. It does not ease the work of the developers.
(We have a 90 or 180 days policy to mark issues as stale. If there are no comments within 7 days of an issue being marked stale, then it gets closed)