Comments (10)
Hey thanks for looking to create an adapter! I've considered a separate org for them and will probably do that, just need to get some time to do so, hopefully this week. Probably should have that before releasing but to be honest, I didn't expect people to be so fast to start developing adapters 😅
To answer your questions:
- I believe this was due to a small bug in the core when multiple adapters were present. You should see this fixed now in the latest commit.
- The return type of
results
should be atable<string, neotest.Result>
(see here https://github.com/rcarriga/neotest/blob/master/lua/neotest/adapters/interface.lua#L32) which maps the test IDs to results. Otherwise the core has no way to know what result corresponds to what test. - Had the same issue of dynamic tests for neotest-plenary and I suspect this will be a problem in other languages too. I know VSCode's Jest integration will actually show the dynamic tests as separate tests but that requires a very strong integration which I think is overkill. Instead what I did for neotest-plenary was to check where the dynamic test was created (using the debug module) and matched it to the range of a static test. When constructing results the result object allows for multiple error messages so that multiple dynamic tests results can be aggregated in one. So for your example the result for
TestAdd
would contain the errors forTestBothZero
,TestBothPositive
andTestBothNegative
. Of course this is just a suggestion and nothing about the interface requires that. Also not sure how possible that is without integrating with go. I've looked at wrapping go's test module before and it is a bit of a beast)
from neotest.
Thanks for the fix and the pointers @rcarriga, regarding point 2 on the return for results, is the correct way to handle this then to iterate the tree somehow and match each result output from the test runner to a node of the tree? how do you account for ways that the tests might have been run? do you need to?
from neotest.
Well for plenary and python when collecting the results, it is possible to derive the test ID from the result. I'm not sure what info go test
provides when giving results so I can't be very specific. I should note that the position IDs assigned to each node of the tree is totally arbitrary, you can change them to whatever suits your needs (well in theory, I may have made an assumption somewhere but that would be a bug) as long as they are unique.
how do you account for ways that the tests might have been run? do you need to?
I'm not sure what you mean by this, could you give an example of ways a test might be run?
from neotest.
I ended up using the tree:iter
method and mapping each test name to each node which seemed to work. Not sure if that would work as well for larger test scopes like the whole suite etc.
from neotest.
@rcarriga seems to work well enough now, so if you're ok with it will open a PR to add it to the list of adapters (it's still pretty beta though). One thing I'd still like some help with is I'd like to change the output content. I use the -json
flag, so the test runner gives me easily parsable output, but that means that opening up the test output just shows JSON which isn't that readable. I'm able to collect and parse the test output, so I can re-generate the string that you'd otherwise get from a normal run of go test
but not sure how to feed it into neotest for the output function
Other things I'll eventually want to tackle are
- table/list based test cases
- Different ways of running tests other than just test, file. I'd like to add an easy way to test packages not sure exactly how to expose that command
from neotest.
Great to hear it's working! Happy to add it to the list.
For showing readable output you could create a tempfile using tempname()
, write the reconstructed data to it and then set the output
field of the result objects. It's set automatically by the core client if not present to the output of the process.
I'd like to add an easy way to test packages not sure exactly how to expose that command
Not too familiar with go beyond the basics, can multiple packages share the same directory (meaning that running a directory wouldn't work)? It may require an additional position type to be added to core to represent it if so
from neotest.
@rcarriga that worked re. saving output to a different file and then using that path 👍🏿. One case where I'm not sure if this works is when for whatever reason no test file is found, in this case there is no result to point my output file to, so it just uses the fallback. Tbh the case I'm explaining is an odd one since it should definitely not be saying there is no test, but I'll dig into that, I'm just wondering if there's a way to change the fallback output file to one of my own making even if there are no results
Re. the packages, I believe that is invalid in go and all files from a package must be within that folder, so I guess just using the directory runner would work.
from neotest.
if there's a way to change the fallback output file to one of my own making even if there are no results
You can return a result object for any position including namespaces, files and directories. By default they're just aggregated from child tests. So just iterate through the tree and set the result output for each one to your custom one.
Re. the packages, I believe that is invalid in go and all files from a package must be within that folder, so I guess just using the directory runner would work.
Good to hear 👍
from neotest.
@rcarriga thanks for your help, now the project is up I'll close this out. If I have any issues with getting other stuff working, I'll tag you in an issue on that repo if that's alright. Hopefully shouldn't be frequent.
from neotest.
Sounds good to me, thanks for contributing!
from neotest.
Related Issues (20)
- [BUG] nested_tests causes test output from stdout/stderr to be printed undesirably
- [BUG] Files containing no tests shouldn't show up in summary
- [BUG] subprocess fails on non-default environments HOT 1
- Passing additional test arguments to runner HOT 1
- Feature Request: Set Notification Levels
- [BUG] Getting error "Future already set" and output_panel is empty for python tests HOT 7
- [Feature Request] Boost.Test supporting HOT 2
- Deprecation warnings on neovim 0.11
- [BUG] Summary opens, but no help HOT 2
- Graciously handling DAP failure on multistep (build then run) languages HOT 1
- [doc] Replace README recommendation of neodev with lazydev
- New Adapter: neotest-ctest - A neotest adapter for C/C++ using CTest as a test runner HOT 1
- [BUG] ImportError while importing test module HOT 3
- [BUG] "No tests found" when opening the summary window rigth before running tests the first time
- [BUG] Java file watcher does not work as the jdtls is marked as an invalid lsp HOT 1
- Lazy load adapters HOT 1
- [Question] Subprocess with `--clean` flag
- [Feature Request] Enable setting custom environment variables for summary runs HOT 2
- [Feature] option to hide the adapter name
- [Documentation] RunSpec stream clarification HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neotest.