I'm running into this weird problem with Google Test using Visual Studio 2012. I can successfully set up tests and they run just fine. However, when I make change to any code in the test project and build the project, I receive LNK2005 errors, like this one:
Error 3 error LNK2005: "private: virtual void __thiscall writeStreamTest_writeRandomDouble_Test::TestBody(void)" (?TestBody#writeStreamTest_writeRandomDouble_Test##EAEXXZ) already defined in UtilsTest.obj C:\Users\cye\Desktop\codeCPP\unitTest\unitTest.obj unitTest
However, when I change the name of the test, the test runs fine again. But it not only runs the tests after the name change, but also the tests with the old names. Like this:
[==========] Running 4 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 4 tests from writeStreamTest
[ RUN ] writeStreamTest.writeRandomDouble
[ OK ] writeStreamTest.writeRandomDouble (0 ms)
[ RUN ] writeStreamTest.writeRandomInt
[ OK ] writeStreamTest.writeRandomInt (0 ms)
[ RUN ] writeStreamTest.writeRandomDouble2
[ OK ] writeStreamTest.writeRandomDouble2 (0 ms)
[ RUN ] writeStreamTest.writeRandomInt2
[ OK ] writeStreamTest.writeRandomInt2 (0 ms)
[----------] 4 tests from writeStreamTest (3 ms total)
[----------] Global test environment tear-down
[==========] 4 tests from 1 test case ran. (5 ms total)
[ PASSED ] 4 tests.
It appears that the tests that were included in the last build would be left over. Therefore when I build the code with the same test name, compiler would complaint that the test with the same name already exists.
If I try to comment out all the tests, then call RUN_ALL_TESTS(), the tests that were included in the last build would still run. If I make change and build again, no test will run.
I'm very confused about this issue. Even after I clean and rebuild the project this issue would still occur.
Anyone else ran into this problem before? Thanks very much!
Related
I have read a few topics about errors: cygwin_exception::open_stackdumpfile: Dumping stack trace to program.exe.stackdump
But I can't find something that fits my situation.
This is my project: https://github.com/InzynierDomu/LED_tester
I got error in UT:
Building...
Testing...
[==========] Running 9 tests from 3 test suites.
[----------] Global test environment set-up.
0 [main] program 751 cygwin_exception::open_stackdumpfile: Dumping stack trace to program.exe.stackdump
0 [main] program 751 cygwin_exception::open_stackdumpfile: Dumping stack trace to program.exe.stackdump
[----------] 3 tests from PWM_controller_test
[ RUN ] PWM_controller_test.active
[ OK ] PWM_controller_test.active (0 ms)
[ RUN ] PWM_controller_test.set_pwm_up
================================================================================================================================================================================= [FAILED]
I have very similar test in test/native/Color_tester_controller_test and test/native/PWM_controller_test. The first one works properly, the second not with that test.
TEST_F(PWM_controller_test, set_pwm_up)
{
EXPECT_CALL(hal_mock, set_PWM_output(1));
EXPECT_CALL(view_mock, update_duty());
uut.keyboar_reaction(Cursor_move::up);
}
I stack, and maybe anyone has some idea?
EDIT:
It's only Cygwin gcc problem, on MinGW gcc it's work fine /:
[----------] 2 tests from VideoMgrTest
[Blast] Log directory is: C:\ProgramData\VMware\VMware Blast
[ RUN ] VideoMgrTest.createVideoMgr
unknown file: error: SEH exception with code 0xc0000005 thrown in TearDown().
[ FAILED ] VideoMgrTest.createVideoMgr (1 ms)
[ RUN ] VideoMgrTest.getFBAddress
unknown file: error: SEH exception with code 0x5 thrown in the test body.
[ FAILED ] VideoMgrTest.getFBAddress (3 ms)
[----------] 2 tests from VideoMgrTest (8 ms total)
[----------] Global test environment tear-down
[==========] 10 tests from 4 test cases ran. (226 ms total)
[ PASSED ] 8 tests.
[ FAILED ] 2 tests, listed below:
[ FAILED ] VideoMgrTest.createVideoMgr
[ FAILED ] VideoMgrTest.getFBAddress
I am getting a failure in Google UT. I have provided the funtion definition as given below. Ita failing with a SEG exception. I know it is access denied but i dont know what is being acceseed
void VideoMgrTest::TearDown()
{
VideoProducerInstance::DestroyInstance();
mVideoMgr = NULL;
}
Runtime exceptions are hard to pin down, and the code snipped you provided are unfortunately insufficient to be of any help.
If you are using Visual Studio to run your unit tests (e.g. using the google test adapter plugin), remember that you CAN debug those tests and that you can enable the capture of run time exections (they are not captured by default). The answer given to a similar question may be of help to you here.
In any case, if I had to give a guess, I'd suspect that a access of a nullpointer is the source of your troubles.
I've a c++ test class implemented using googletest, so it is perfectly passing on Xcode with following output:
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from test_fixture
[ RUN ] test_fixture.test_name
[ OK ] test_fixture.test_name (65609 ms)
[----------] 1 test from test_fixture (65609 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (65609 ms total)
[ PASSED ] 1 test.
But when I try to run the same test on terminal by using ctest command it is giving an strange error Unexpected format: with following output:
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from test_fixture
[ RUN ] test_fixture.test_name
Unexpected format: [ RUN ] test_fixture.test_name (it is always printing the above line)
<end of output>
Test time = 29.72 sec
For both Xcode and ctest, the same iOS simulator used, I don't understand why the test output giving conclusion as "FAILED" or "PASSED". I've searched a lot for that error and couldn't find any reasonable answers, so please help.
Update:
It has turned out the ios simulator tool ios-sim has a problem with apps that runs longer than 30 secs (I tried with a googletest class with three empty functions which has delay of 15 secs between them, app crashed on second one), simulator crashes the app but didn't find why yet.
It turns out iOS Simulator tool I was using https://github.com/phonegap/ios-sim.
I've emptied our test classes and added 3 test functions with delay of 15 secs between, if the app runs longer than 30 seconds, ios-sim crashes it.
The solution for this case is to use real devices with the similar project: https://github.com/phonegap/ios-deploy
I use GoogleTest extensively and the output in the cosole looks like this:
When I run the same from within Eclipse (using Eclipse Mars latest as of today) I get the following output with no colors and junk characters (are not visible just pasting the output here):
Running main() from gtest_main.cc
[0;32m[==========] [mRunning 3 tests from 1 test case.
[0;32m[----------] [mGlobal test environment set-up.
[0;32m[----------] [m3 tests from NloptAdapterSuite
[0;32m[ RUN ] [mNloptAdapterSuite.testQuadraticFunction1
[0;32m[ OK ] [mNloptAdapterSuite.testQuadraticFunction1 (1 ms)
[0;32m[ RUN ] [mNloptAdapterSuite.testQuadraticFunction1WithNoise
[0;32m[ OK ] [mNloptAdapterSuite.testQuadraticFunction1WithNoise (1 ms)
[0;32m[ RUN ] [mNloptAdapterSuite.testQuadraticFunction2
[0;32m[ OK ] [mNloptAdapterSuite.testQuadraticFunction2 (1 ms)
[0;32m[----------] [m3 tests from NloptAdapterSuite (3 ms total)
[0;32m[----------] [mGlobal test environment tear-down
[0;32m[==========] [m3 tests from 1 test case ran. (3 ms total)
[0;32m[ PASSED ] [m3 tests.
How can this be fixed to have the same output?
The ANSI Escape in Console plugin that greg-449 linked above worked great for me. After installing it, the gtest output looks like:
I'm on Neon.2 (Eclipse 4.6.2).
Hi I was running my unit test in Jenkins when I encountered this error
Results Top Level Tests
------- ---------------
Failed FailedTest1
Failed FailedTest2
Failed FailedTest3
0/3 test(s) Passed, 3 Failed
Summary
Test Run Failed.
Failed 3
Total 3
Results file: C:\Program Files (x86)\Jenkins\workspace\BatchTests\BatchTestsResult
Test Settings: Default Test Settings
Run has the following issue(s):
Warning: Test Run deployment issue: The assembly or module 'Microsoft.Practices.ServiceLocation' directly or indirectly referenced by the test container 'C:\Program Files (x86)\Jenkins\workspace\BatchTests\mml\bin\release\syncfromgbaseeucbatchtests.dll' was not found.
Build step 'Run unit tests with MSTest' marked build as failure
Finished: FAILURE
what is even worse that I do not unstand is that I did not have the reference of Microsoft.Practices.ServiceLocation specified in my project reference, therefore i do not know why the dll is looking for it.
The unit tests however do run properly from visual studio 2012 instead. Any help is appreciated.