Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test UI runs each test separately #306

Closed
lukaszsamson opened this issue Mar 5, 2023 · 9 comments
Closed

Test UI runs each test separately #306

lukaszsamson opened this issue Mar 5, 2023 · 9 comments

Comments

@lukaszsamson
Copy link
Collaborator

Currently (1.14) elixir does not have any easy way of tracking test progress and getting test results programmatically. We can experiment with a custom formatter that outputs JSON or streams jstest compatible events to stdout

@Coffei
Copy link

Coffei commented May 31, 2023

You can run mix test --trace, which outputs a good amount of information, although formatted for humans.

@lukaszsamson
Copy link
Collaborator Author

That's a nogo. You'd need to parse stdout and tests can pollute it.

@Coffei
Copy link

Coffei commented May 31, 2023

True. We've been also using JUnit formatter to interface ExUnit with Gitlab/Bitbucket CI systems (https://hexdocs.pm/junit_formatter/readme.html). That would probably be better, but I have no idea how to plug it into an existing project when running tests. Also, there's an alternative VSCode plugin for running tests - Elixir test explorer, but it seems it is using the --trace method.

@lukaszsamson
Copy link
Collaborator Author

I know and used JUnit formatter. The downside is it's not trivial to setup and it cannot stream results in realtime

@felipeelias
Copy link

@lukaszsamson has any work done related to this? I'm looking for ways to contribute and the test runner is one of the areas that interest me.

The downside is it's not trivial to setup and it cannot stream results in realtime

What would be the most appropriate way to make this work? A custom formatter I believe, but in which format and what do you mean by "realtime"

@lukaszsamson
Copy link
Collaborator Author

I haven’t done anything concrete yet. I have a custom mix task that returns exactly the same test files that mix test does. I plan to replace the typescript implementation with that. On the test runner side I can think of two ways. One is custom formatter that streams results in json to stdout and typescript parser. The second and IMO easier is changing the test runner to make it run tests in debug adapter with noDebug option and add an exunit formatter that emits results as DAP output events. I implemented noDebug in 0.17 and added support for intercepting custom DAP messages on the typescript side.
The biggest problem with the first approach is injecting the custom formatter to client project. In case of the second one we run the code via debug adapter and can inject our code and configuration relatively easily

@felipeelias
Copy link

One is custom formatter that streams results in json to stdout and typescript parser.
The biggest problem with the first approach is injecting the custom formatter to client project.

From your comment, I understand that the challenge here is to include this custom formatter as a dependency, right?

@omh
Copy link

omh commented Jan 4, 2024

👋 Would it be possible, while we wait for a better solution, to just run all the tests in one go and report the result once all tests finish? I think in many cases that will be waaay faster than running each test individually. Especially on bigger projects where the start up time can take some seconds.

@lukaszsamson
Copy link
Collaborator Author

That's an option but then we loose info which test failed. It's either all red or green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants