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

Add test helpers #470

Open
PoignardAzur opened this issue Oct 22, 2024 · 4 comments
Open

Add test helpers #470

PoignardAzur opened this issue Oct 22, 2024 · 4 comments

Comments

@PoignardAzur
Copy link
Contributor

AccessKit currently helps you hook into platform APIs, but it doesn't provide an API to maintain and edit a node tree locally for unit tests.

Ideally, my testing workflow would be:

  • Create a PersistentNodeTree in my test harness.
  • Create a TreeUpdate using my business logic.
  • Apply the update to my PersistentNodeTree.
  • Query some information about my PersistentNodeTree, and check that it matches my expectations.

"Query some information" could mean getting a Node's value, checking that a given node is in the tree, that a node is another node's child, or just getting a debug representation so I can use insta::assert_debug_snapshot.

Any thoughts?

@DataTriny
Copy link
Member

Hello @PoignardAzur,

While its primary focus is not unit testing, how about kittest?

I think our main issue at the moment is that platform adapters each expose slightly different APIs, so providing some sort of testing helper would either mean adding a new adapter that UI toolkits would have to implement, or force testing functionalities into existing adapter. I'm not sure what's the best option.

@PoignardAzur
Copy link
Contributor Author

I think our main issue at the moment is that platform adapters each expose slightly different APIs,

I don't need to interact with platform adapters. The tests could be purely-platform agnostics: my framework is already producing accessibility nodes, I only need accesskit to store them somewhere.

@mwcampbell
Copy link
Contributor

If you only need a way to store nodes and query them in your tests, you could use accesskit_consumer directly. This is what the third-party kittest project does, apparently using one of our platform adapters as a starting point.

@PoignardAzur
Copy link
Contributor Author

Alright, I look into that crate.

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

No branches or pull requests

3 participants