How to work around CrossHair Output Values #215
Replies: 1 comment 2 replies
-
First, let me apologize for sitting on this for so long - it completely slipped my mind. In the future, don't hesitate to ping me if I don't respond in a few days. Okay, so I completely understand your desire to generate meaningful test inputs - this is a pretty universal problem for unit test generators. Unfortunately, I'm not sure how we'd build a rational feature like you describe that would work for arbitrary data structures. If you have a more fleshed out proposal for how it might work, I'd be happy to consider it. (and happy to point you around the codebase once I understand more concretely how it should work) Let me also propose a workaround: in theory, you could temporarily add constraints at the top of your function that immediately exits when the input that doesn't match the inputs (e.g. the strings) that you'd like to see. For example:
Afterwards, you can delete the test case(s) that relate to this temporary code block, and the remaining tests are hopefully the ones you want. |
Beta Was this translation helpful? Give feedback.
-
Hello!
I'm adventuring myself using CrossHair coverage and notice that all output values are empty strings, 0's, empty lists, and stuff like that.
I want to get values accordingly with a given context (so they make more sense in a test). For example, given a list of strings that matches the context, it'll choose one string from that list instead of just using an empty string.
But I'm new to CrossHair and don't know where to begin. I tried to look a little bit into the code but didn't get too far. Can someone guide me?
Beta Was this translation helpful? Give feedback.
All reactions