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

neotest-ctest adapter #241

Open
orjangj opened this issue Jun 16, 2024 · 3 comments
Open

neotest-ctest adapter #241

orjangj opened this issue Jun 16, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@orjangj
Copy link

orjangj commented Jun 16, 2024

First of all, I want to thank you for making this plugin. I've been using it for quite some time now and it works like a charm so far.

Anyway, I found this issue #68 and I noticed that neotest was brought up in the discussion.

I have written a neotest adapter for C/C++ using CTest as a test runner. You can find it here: https:/orjangj/neotest-ctest. It currently supports basic test macros from both GoogleTest (TEST, TEST_F) and Catch2 (TEST_CASE, TEST_CASE_METHOD, SCENARIO). I plan to add support parameterized tests (if possible) and add support for more test frameworks as well.

I'm not sure where to take it from here, but I figured you might want to have a look at it and maybe reference it in the README?

Let me know what you think. If not, you can just close this issue :)

@orjangj orjangj added the enhancement New feature or request label Jun 16, 2024
@Civitasv
Copy link
Owner

I think this is very interesting! Currently, we parse all tests using ctest command and no other dependencies, lacking some features. But I'm not familiar with neotest, to my understanding now, I think it's like a middleware which provides unified API to support multiple test framework, right?

@orjangj
Copy link
Author

orjangj commented Jun 28, 2024

Yes, in short neotest provides a unified API and UI to run tests, while neotest adapters will take care of constructing commands to run tests in addition to parsing test results. One of the things that makes neotest such a great plugin is that you can use it for many different languages/frameworks (provided there is an adapter available) and that you get feedback on passing/failing test in the sign column. Neotest can also display test output (parsed by adapters) in a floating window, show errors through nvim's diagnostics (if supported by the adapter), and more.

neotest-ctest bridges neotest, ctest and a few supported C/C++ test frameworks. neotest-ctest is primarily limited by its ability to parse test cases through treesitter (which determines how neotest knows what tests you want to run). There's bound to be some shortcomings here considering that building treesitter queries can be quite challenging for some of the test case macros (especially parameterized tests). After that, the adapter will simply query ctest for runnable tests and build the appropriate ctest command(s) to run a single test case, all tests in a file or all tests in a directory/workspace depending on how you invoked neotest's API.

neotest-ctest does not manage cmake based projects or compile tests, which is why I've recommended cmake-tools.nvim as a companion plugin in my readme :)

@mjrogozinski
Copy link

I was looking for a plugin like this one.
In the project with multiple test binaries, I would like to be able to say "run this test" and only the test binary (CMake target) containing the test would be rebuilt.

Integration of CMake with testing frameworks is needed. Thank you for your work.

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

No branches or pull requests

3 participants