ronag
ronag

Reputation: 51283

Creating a test project

I have a solution consisting of several library project and one application project.

I want to create a separate application test project. However, my problem is how I can write test for the application project since I can't link to it? I've added the application project as a reference in "Common Properties", but I get LNK1120 probably because the application project doesn't generate a lib file to link.

How do I create a separate test project for a project with application as configuration type?

Upvotes: 1

Views: 118

Answers (1)

Preet Sangha
Preet Sangha

Reputation: 65556

I can think of three solutions to this - none 100% as clean as I'd prefer.

  • Compile test code into a test library that is conditionally linked to the application program, and is driven by test input to the program. So in effect you use your own app as the test driver
  • Make you application a shell only and put all unit tested code in to a library that can also be linked into the test app.
  • same as the last one, but compile the code in the library into the app in the application build, but into the library for the test build.

The second would be my choice.

Upvotes: 2

Related Questions