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

Unit tests #835

Open
1 task done
champignoom opened this issue May 3, 2023 · 3 comments
Open
1 task done

Unit tests #835

champignoom opened this issue May 3, 2023 · 3 comments
Labels
feature Issues related to feature proposals. Please attach a module.

Comments

@champignoom
Copy link
Contributor

Issues

  • I have checked existing issues and there are no existing ones with the same request.

Feature description

It appears that some fix (like ffabc4c) might cause new problems (like #831 #833). Some simple unit tests might help, for example using https://github.com/nvim-lua/plenary.nvim#plenarytest_harness.

Help

Yes

Implementation help

No response

@champignoom champignoom added the feature Issues related to feature proposals. Please attach a module. label May 3, 2023
@d-r-a-b
Copy link
Contributor

d-r-a-b commented May 3, 2023

Sevoris and I were discussing this just the other day in dsicord, and it's nice to see that someone else is thinking along the same lines.

I recall from looking through the git history that tests were part of the github workflows/dev tree for a while and then were eventually stripped. My sense is that they may have been stripped because they had very high maintenance churn before norg-spec stabilized on 1.0. Given that the spec is now in a much more stable place, could a core dev comment on whether my sense is correct and whether they agree that re-implementation of a test suite makes sense at this time?

There are a fair number of behaviors for which you might need something closer to an integration test to test reliably. screen.lua looks like a promising choice; (neo)vim also includes :h testing for testing such behaviors although I find it slightly opaque. https://vimways.org/2019/a-test-to-attest-to/ is a very nice introduction to how YouCompleteMe author approached setting up a vim testing framework and goes into the basic ideas needed to implement a simplified version of the test framework ultimately used for the YouCompleteMe test suite, which is heavily inspired by the :h testing approach.

@vhyrro
Copy link
Member

vhyrro commented May 4, 2023

Yep now that we're past 1.0 I'm completely happy with implementing some form of advanced test suite. What would be fantastic is if each module could specify its own tests, for instance an individual module could have:

module.tests = {
	["Test name"] = function(fns)
		fns.some_assert(false, "whatever")
	end,
}

This way it can easily test public behaviours (whether the API is behaving correctly) and private behaviours (if the inside machinery works).

fns here could be a table with a handful of functions that a testing function may need, including stuff from screen.lua or whatever else.

After that I assume we implement :NeorgRunTests or something? I don't think it should belong in :Neorg ... because it's a feature exposed by the core, not by a module 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issues related to feature proposals. Please attach a module.
Projects
None yet
Development

No branches or pull requests

3 participants