Unit test execution in docker container #93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
First of all, thank you so much for this wonderful plugin. I had been looking for the capability to run my unit tests without exiting my favorite neovim editor for a long time.
Unfortunately, the development environment of my professional project requires executing the unit tests inside a Docker container instance. As a consequence, after the delegated execution, it is required to use a report in file format to retrieve the execution results. This solution is less elegant than your wrapping of the python script from Lua but I have found no other way.
Additionally, the default report format of pytest is not easy to parse in Lua, which is why I have used the python module
pytest-json
. The report is parsed to provide the result to the neotest root plugin.To integrate all of this into your solution, I have added a few configuration properties to your plugin to be able to determine when a docker instance must be used and if so, which instance.
The
use_docker
parameter allows the plugin to build the command to launch locally so test execution happens in the docker instance. In the following example, this parameter is a static value but it could also be replaced by a function to allow conditional "dockerization".The
container
parameter provides the name of the container to use for test execution. This parameter can also be a function to dynamically determine the name of the container.For example, in the following configuration, I use the directory path as discriminator.
Feel free to say if something looks wrong to you. I am a complete beginner with Lua language and there are many things I might have missed.