julia-vscode / TestItemRunner.jl

Run Julia test items
MIT License
67 stars 11 forks source link

Requires directly adding `Test` as a dependency. #35

Closed JamieMair closed 1 year ago

JamieMair commented 1 year ago

Requires having Test as a direct dependency of the project, instead of being part of the [extras] dependency. E.g. it would be nice to work when the Project.toml file looks like:

name = "MyPackage"
uuid = "some-uuid"
authors = ["author and contributers"]
version = "0.1.0"

[deps]
OtherPackage = "some-uuid"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"

[targets]
test = ["Test", "TestItemRunner", "TestItems"]

Without having to list Test under the [deps] section.

davidanthoff commented 1 year ago

That should work just fine. The one thing that you do need to put in the [deps] section is TestItems if you want to use inline tests that are just part of your regular package code. But it is a very lightweight dependency: https://github.com/julia-vscode/TestItems.jl/blob/main/src/TestItems.jl.

JamieMair commented 1 year ago

I was able to figure our why I was getting the following error in the UI when trying to run the tests:

Unable to load the `Test` package. Please ensure that `Test` is listed as a test dependency in the Project.toml for the package.

I hadn't yet added the [targets] listing as below, but the error goes away if you add Test to the [deps] section, which caused the confusion. This is fixed now by adding the [targets] section:

[targets]
test = ["Test", "TestItemRunner", "TestItems"]