Hi,
I am aiming to follow a project structure like so (apologies for peculiar formatting, the editor is removing whitespaces at the start of the line):
my-wallet-app
└── daml.yaml
└── src
…└── Wallet
… …└── Main.daml
… … └── … (all other project files)
… └── WalletTest
… …└── MainTest.daml
… …└── … (all other project files)
I know that I can set source setting in daml.yaml to point to src/Wallet folder, but then daml test command doesn’t pick up any of the files under test directory.
Is there some way to keep main source files and test source files in the same daml project and only have main source files content included in the DAR file? Obviously I can split the project into two DAML projects as a workaround, but was wondering if there some daml compiler setting I don’t know about.
We strongly recommend implementing test scripts in a separate project. The main downside of this recommendation is that in this setup the templates from the main project are imported into the test modules via data-dependencies, which means that in Daml Studio any changes you make to the main project will not propagate into the test modules until the main project is rebuilt. There’s a workaround for this, which allows modifications to the main project modules to propagate to test modules right away without the need to rebuild the main project, but this workaround requires a rather complicated project structure with symlinks. For more details, see this previous thread.
@a_putkov Why do you recommend having test scripts in a separate project/dar? What are the downsides to having it in the same dar as the code being tested?
Generally your tests are going to change more often than your Daml models. If you keep them in the same DAR, your tests and your templates share a package id. So anytime you change a test you also change your templates and you now either need to ignore certain changes or run a model upgrade on your ledger every time.
If you keep your tests separately on the other hand, you can change them freely without any impact to the templates on your ledger. In fact, you don’t even need to upload the dar containing the tests.