-
Notifications
You must be signed in to change notification settings - Fork 102
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 support for data driven tests #102
Comments
Theoretically this can be solved by recombining this pull request: #274 with this pull request: google/googletest#2253 Everything new is long forgotten old. ;-) |
The idea behind this issue is slightly different: Currently, parameterized gtest tests are "flattened" and registered with VS as "normal" tests. However, the VS test framework has an own notion of parameterized tests called data-driven tests (they are linked at the very top of the issue). This issue only is about mapping the gtest notion into the VsTest notion. I have never worked on this issue because, as @frboyer has pointed out above, it would not be possible to run single tests any more (in contrast to the current way). Maybe one should double-check if this is still the case because VS' test explorer has advanced quite a bit since 2018... |
Ok. This coechoes with what I'm trying to create on my own currently. With two changes above you can free naming and free source code location to any tests which you write. But concerning data driven unit tests - I think requirement will go outside of normal google unit test - since google unit test have a mechanism to verify one parameter against second one - e.g.
And that goes crazy after it's not i anymore and direct mapping from key to value is not possible I had simpler idea. My idea is that application itself has built-in logging mechanism and As a base logging facility I'm using spdlog, see https://github.com/gabime/spdlog. I've selected spdlog among other loggers because of it's speed and it's also covered by unit testing See also: My idea is that application will have built in global field for log activation - for example:
which would be by default disabled. Code will be instrumented using bit field definition, for example:
and code would be instrumented like this:
This in a turn would mean that release / production code will not have any tracing / logging as an active. Test application in a turn would look something like this:
As for verification functionality, I have made sink similar to basic file sink, only instead of writing log, it performs also reading of log file and comparison. https://github.com/gabime/spdlog/blob/v1.x/include/spdlog/sinks/basic_file_sink.h First test application run would produce one or many logs, logs will be stored in version control system. In CI environment logs won't be recorded anymore, but verification against existing log files will be performed. There are still more open questions, which I want to tackle later on - for example how to deal with multi-threading, and what to log, so that logging would always contain only relevant information and also can be used for testing as well. Also making sure that log level would be more or less "atomic", meaning that you cannot add or remove additional log traces later on without good reason. I guess one more thing needs to be mention - I'm not using anymore any google unit test Good thing about this - is that if you place breakpoint, where it will try to throw exception - you will halt at that very point where execution differs - with good luck - you can check call stack and all local variables to identify what is the problem - with not so good luck - you will be still close to problematic point. If you're dealing with relatively complex application - reaching correct problematic point of execution can be very refreshing - especially if you're not familiar with code, or even if you're familiar, but cannot say what is wrong. |
Logging binary data instead of textualOne more thing - sometimes you might want to gather more complex log line with more relevant information - for example, like this:
In theory it's also possible that at some point of time it would make sense to switch to binary formatting instead of textual - as log files will consume less disk space and it will be faster to produce them. But binary log files would require separate binary log viewer, which in a turn more complex to support. Also when checking version control history back (e.g. git history) - it's more difficult to check binary differences than ascii differences. So suspect it's possible to achieve , based on examples in here: But then need to think but deeper how arguments "collecting" would happen in application - instead of string - see code above. So suspect binary "collecting" is possible to support, but need separate binary viewer and need to have mechanism to collect traces instead of string. Logging floating points, precisionMy idea that even if you transfer coordinates - you loose some precision (E.g. 2 decimals after comma), but it's not so relevant in most cases. Logging binary dataIf you trace binary, mostly first 10 bytes tracing is sufficient to identify if binary data is the same or not. If insufficient - then can use one of binary hashing algorithm and log only hash instead of binary.
For more info, see: Logging float will whole precision consumes more disk space, which is in most cases not needed. |
Data driven tests appear to be VisualStudio's notion of Google's parameterized tests. We have to figure out:
TestResult
objects via the properties bag? How does aTestProperty
object have to look like such that it is displayed properly in the test explorer?The text was updated successfully, but these errors were encountered: