-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Try to differentiate between null and empty strings in test theories #494
Conversation
Overall, looks good. Gives us a place to make changes if we find any more special values that need differentiated. I made one change: I grouped the new tests in an explanatory test list. Checking off a few other potential special values
Example of breaking reference type type ClassA(i: int) =
let i = i
testTheory "I am theory" [ClassA(5); ClassA(4)] (fun (refType: ClassA) -> true) I'm not sure how common this reference type scenario is. The empty vs null one seems quite common though, and it's worth getting a fix in for that at least. |
Also, thanks for the PR! |
I don't know if there are any potential locale specific issues that might occur?
I can't recall offhand what NUnit/XUnit do for that, will have to test. |
… leading/trailing whitespace more visible
Using NUnit and XUnit theories as a reference is a great idea |
C# attributes can only accept constant parameters. Makes sense that class instances are out. That's interesting that TestCaseSource behaves differently than the attributes. Did you check out xUnit too? |
Thanks for the research! Maybe we could mimic the xUnit approach to class rendering. That could open new issues with special characters in test names though... I think it's worth merging the string/null fix by itself, since that's a fairly common issue. |
I don't recall having used classes with TestCase myself (it's usually base types like strings, numbers, enums). so making the string case work fixes my problem.
I'm not sure if putting that data in the test names would have issues if the class instances had dynamic fields in them? (e.g. say you had a test class instance with a time stamp or guid or some such property in it, trying to render that as part of the test name rather than just in the results might be problematic?) |
The characters that cause issues (that I'm aware of) are I've also seen some filter issues with characters like |
Oof. Glad I thought to test before pushing the packages. |
A fix is PRed ionide/ionide-vscode-fsharp#1999 |
Sorry, thought I'd tested that when I made the screen shots, must not have though :-( My comment about dates etc was more about 'dynamic' data, as in what will the test explorer do if the test name were made of data that might be different between runs (maybe not common, but could happen with class types?) - although maybe you could have a Your comment about |
Just accidentally fell over a related situation here - If I try to give a testTheory arrays of strings as inputs, then each array has the same string representation so you get a |
While not very elegant, a workaround could be to give each case a data point to differentiate it. I.e. Actually, we could potentially generalize such an approach. Automatically add a case identifier to make sure each case is unique even if the arguments don't have distinct string representations. |
refs #493
Some testing to pin down where the issue is - not sure if this is the best apporach to fixing it, or if there are other types than strings that might have similar issues.