简体   繁体   中英

VisualAssert Testing in C++, Loading a test fixture

Good day, I am learning Testing in Visual Studio C++ and I have several tutorials which I have followed. I am trying to load a test fixture. I have tried to put the test .cpp file in many different places but it will still not pick up on it when I click on "Run Tests" or "Run Tests without debugging"

In the tutorials I found, they seemed to load into the Test Explorer automatically, but in mine is an icon with a X + (PROJECTNAME).EXE and when I hoover over it I get

the process exited without registering with the agent... this is due to the model not containing any test fixtures...

How can I load my tests into the Test Explorer...or register them with my project...

I've tried right click and "Add Fixture..."....

but that just starts a new test file and I have the same problem.

Anybody know how I solve this issue?

The most likely reason is missing the environment variable CFIX_HOME . Try to set it (typically to "c:\\Program Files (x86)\\VisualAssert\\") and restart VS. Also update your project's setting by including the following paths:

C/C++ -> General -> AdditionalIncludeDirectories $(CFIX_HOME)\include
Linker -> General ->AdditionalLibraryDirectories $(CFIX_HOME)\lib\amd64
I faced the same problem exactly as you described and solved it that way.

One drawback of including cfix/Visual Assert code right into your project is that your .exe will require cfix.dll for start. This behavior, however, helped me to detect the problem :)

Update from @Neutrino makes sense. I obtained other problems:

  • red X on the project name in the 'Test Explorer' window appeared again, and its properties contains exception message: Cfix.Control.CfixException: Test module not found. ---> System.Runtime.InteropServices.COMException (0x8004B009): Exception from HRESULT: 0x8004B009
  • 'Test Explorer' and 'Test Run' windows do not fit into their positions on each VS2008 run, but instead they stay above.

Probably this is due to installation of Visual Assert gone bad somewhere on W7 x64 + VS2008

I had the same problem. CFIX_HOME environment variable and VS 2008 paths were set correctly. I'd copied the i386 cfix.dll to the same directory as my test exe.

Executing the command:

"%CFIX_HOME%\bin\i386\cfix32.exe" -exe "%CD%\VisualAssertTest1.exe"

Resulted in cfix outputting this and then exiting.

cfix version 1.6.0.3683 (fre)
(C) 2008-2010 - Johannes Passing - http://www.cfix-testing.org/
Hello

The 'Hello' is just trivial output from my test program so I can be assured it loaded correctly.

Only when I copied my exe into the %CFIX_HOME%\\bin\\i386\\ did it work at all and then all it did was output

cfix version 1.6.0.3683 (fre)
(C) 2008-2010 - Johannes Passing - http://www.cfix-testing.org/
[Success]      VisualAssertTest1.MyTest1.Test

Then I tried to get it to run using the Visual Studio run command. I modified my project settings as follows.

Configuration Properties\Debugging:
    Command: $(CFIX_HOME)\bin\i386\cfix32.exe
    Command Arguments: -exe "$(TargetPath)"
    Working Directory: $(CFIX_HOME)\bin\i386

This runs but you have no way of knowing what happens because cfix32.exe exits immediately and the output is not captured by Visual Studio. Adding the -y option to request cfix32.exe to pause at the end of the test run results in:

-y and -Y are currently not supported in conjunction with -exe

Which is as far as I've got with it.

So to summarize.

It looks like for some reason you don't get any graphical output when testing an exe.

When testing an exe the Visual Studio plugin doesn't detect any of your test cases leaving you with no simple way to select which test cases you want to run.

And running manually in a console window is the only way to capture the output.

All I've ever wanted from a native C++ unit test program was:

  1. To be able to add tests to an exe.
  2. To be able to select and run those tests interactively from inside the IDE.

When I first heard mention of this proogram I thought I'd hit gold, but unfortunately not quite. Still it seems closer to what I'm looking for than anything else I've seen yet so I'll persevere with it for a while.

@Johannes Would be nice to know if it's still being developed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM