Giter VIP home page Giter VIP logo

Comments (10)

rcarriga avatar rcarriga commented on July 19, 2024

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:

  1. 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.
  2. The return type of results should be a table<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.
  3. 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 for TestBothZero, TestBothPositive and TestBothNegative. 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.

akinsho avatar akinsho commented on July 19, 2024

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.

rcarriga avatar rcarriga commented on July 19, 2024

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.

akinsho avatar akinsho commented on July 19, 2024

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.

akinsho avatar akinsho commented on July 19, 2024

@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

e.g.
image

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.

rcarriga avatar rcarriga commented on July 19, 2024

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.

akinsho avatar akinsho commented on July 19, 2024

@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.

rcarriga avatar rcarriga commented on July 19, 2024

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.

akinsho avatar akinsho commented on July 19, 2024

@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.

rcarriga avatar rcarriga commented on July 19, 2024

Sounds good to me, thanks for contributing!

from neotest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.