5

Comma 2020.07 (community edition) has changed the test configuration, and now you can test different things: module, project and so on. However, I can't simply get it to run the usual tests. When I use "All in project" testing, I get this error:

No test source roots in the project: is it properly configured?

I have no idea where to set the source roots, or how to configure it properly. Tests are in the usual place, t/.

jjmerelo
  • 22,578
  • 8
  • 40
  • 86
  • 1
    [A google for "test source roots"](https://www.google.com/search?q=%22test+source+roots%22) makes it clear this is a general IntelliJ thing. The first SO I looked at talks about starting with **Project Structure** (`Ctrl`+`Alt`+`Shift`+`S`) and then arriving at some screen where you add "test source roots in this root". Whatever that means. If that doesn't help, maybe [a google for "source roots"+IntelliJ](https://www.google.com/search?q=%22source+roots%22+IntelliJ) will? Tbh I've literally no IDEA but thought any comment was better than NO idea at all... – raiph Aug 09 '20 at 00:18

1 Answers1

4

When a new project is created or imported, the lib directory should get marked as a source root (where modules live) and the t directory as a test root (where the tests live). Previously, Comma paid no attention to these markings and just hard-coded looking in the t directory for tests, but ongoing work is aiming to support a wider range of project structures, and thus as of a recent release the concept of test root started to matter.

Somehow, you've ended up with a project where the t folder is not marked as a test root. I'm not sure how that happened, but there are ways to try to fix this situation.

One is to re-import the project from source, which should set it up correctly, but will lose run configurations.

An alternative is to open the .iml file in the root directory of the project. In a correctly configured project there will be an entry like this:

    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/t" isTestSource="true" />
    </content>

Yours is probably missing the entry for the t directory with isTestSource set to true.

Future Comma versions will provide a way on the UI to do this, so that one can set up multiple test roots if needed (t and xt for example).

Jonathan Worthington
  • 29,104
  • 2
  • 97
  • 136
  • There's no such thing, I'm afraid. It might be taking the template from an older configuration file, or something, because I keep getting it for new modules. Where would the source for that be so that I don't have to change it by hand for every new project? – jjmerelo Feb 25 '21 at 17:26
  • The UI support for this has been in place for quite a while now; right-click on the directory in the file tree, `Mark Directory As` > `Test Sources Root`. – Jonathan Worthington Feb 26 '21 at 21:08