Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Integration of generative testing #2023

Closed
halgari opened this issue Mar 7, 2025 · 2 comments
Closed

Integration of generative testing #2023

halgari opened this issue Mar 7, 2025 · 2 comments

Comments

@halgari
Copy link

halgari commented Mar 7, 2025

I'm loving tUnit so far, and would love to start integrating generative testing into some of my projects. An example project for this sort of thing is FsCheck. In order to do this we'd need some way to run tests and refine the inputs of a test based on what tests fail.

For those who haven't seen generative testing before, it mostly involves probing a test, if a test takes int it would be run first with 0 then 1, then 100, then -100, etc. until it fails. If the test fails on 50 and not 1 the testing suite then tries 25 then performs a binary search of the input space until a single failing result is found. The report for the failure is then "Test failed with input 42"

I'm not sure how best to integrate this sort of test process. But I'd love to kick off the converstion.

@thomhurst
Copy link
Owner

thomhurst commented Mar 7, 2025

I did experiment with a method on the context like "ReregisterTestWithArguments(Args)" and it'd clone the test but with the new arguments and kick it off.

The logic for data generation could be custom and defined in a Data source generator attribute.

Feel free to have a play. It's marked with experimental.

I don't have any experience with FsCheck, and when I tried to explore, it went over my head tbh.

@thomhurst
Copy link
Owner

See here: https://github.dev/thomhurst/TUnit/blob/4f338e9bc6750afd720d4a4065e97925636fc841/TUnit.TestProject/DynamicallyRegisteredTests.cs

If you had time to play around with it, I'd appreciate feedback on developing it further.

Repository owner locked and limited conversation to collaborators Mar 19, 2025
@thomhurst thomhurst converted this issue into discussion #2125 Mar 19, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants