So I'm pretty new to C++ unit testing, I have worked pretty much exclusively with JUnit. I've been playing around with Google Test on Xcode for a bit now but for some reason when I try to print out failure messages they never show up on the console. Here is the code:
#include "MyFuncs.h"
#include "gtest/gtest.h"
TEST(MinTest, Positive) {
EXPECT_TRUE(findMin(1,2) == 2) << "I'm not printing";
}
I've tried to research why and I can't seem to find the answer which I suspect might be obvious. I've tried adding a new line character and the end and using endl to try to flush the output but that also did not work. Printing to stdout and stderr works just fine within the function, so my question is pretty much if anyone knows why this isn't working?
And, if you are wondering, I have included these in MyFuncs.h:
#include <iostream>
using namespace std;
Edit: Here is the code for findMin
int findMin(int a, int b) {
return a<b ? a : b;
}
And here it the Google Test output:
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from MinTest
[ RUN ] MinTest.Positive
/Users/asocik/Desktop/Testing/Testing/mathTest.cpp:6: Failure
[ FAILED ] MinTest.Positive (0 ms)
[----------] 1 test from MinTest (0 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (0 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] MinTest.Positive
1 FAILED TEST