Google Test only executing one test?
30 March, 2011 § 1 Comment
Earlier today while pair-programming, Angie and I ran into an issue where Google Test was only executing one unit test of the 150 or so in our test suite. We weren’t sure what the cause could be. We switched machines and all the unit tests ran fine on my machine.
We first checked the WinMain entry point to see if some configuration flag of GTest had been accidentally flipped. A quick diff showed us that nothing had changed.
So what could be differentiating Angie’s computer from mine? Well it turns out that Angie really enjoys using keyboard shortcuts and macros to help her do her work. A couple weeks ago I showed her some of the Visual Studio macros that are used in developing for Chromium. Angie saw the list of macros and quickly installed the “Alternate between source and header file”, as well as the “Run the currently selected google test”.
It turns out that the “Run the currently selected google test” works by adjusting the command line arguments that are passed to the GTest executable. This argument sets a filter on the test runner to only run the tests that match the given filter, which in this case happens to be the name of the currently selected test.
As the Jing states, simply clearing out the command argument fixed our problem. If you’re using the macro mentioned earlier, you can also place your cursor outside of a specific test case, run the macro, and the filter will be cleared.
I hope this post comes in handy for anyone else that got stuck in our position.
Great knowledge Jared — just in case I ever hit this issue! I like command arguments even for GUI applications. You don’t think about them much because command arguments are generally though of with command-line applications.