Is it possible to build library used only for the unit testing?

Hi,

I am a newbie to the team system. Currently, we are building a test system based on team test for our existing application. Since the application is quite large, we would start from a small portion of it.

My question here is whether it is possible to build library used only for the unit testing For example, one of the methods is newticket(Ticket ticket). The existing application reads the xml-based queue message from the msqueue and generates the ticket object, then pass it to newticket method. But right now, I would like only generate test case for newticket. So I need a method to generate the ticket object from an xml file. I also can reuse this method to generate ticket object for cancelticket and changeticket methods. Since it is quite a lot of coding to generate the ticket object from an xml file, I would like put it in a library.

Could anybody here explain whether it is possible If yes, could you give the steps doing this or the reference

Thanks a lot.



Answer this question

Is it possible to build library used only for the unit testing?

  • g0nzo

    The final build of a program is based on whats included in that project. So I would assume you have three projects (or should), one for testing, one for the application, and one for the test only class library. In your test project you want to reference the test only class library, in your application project you would not reference it. This way when you build your application it will not be included.
  • arsonist

    Jakeb16:

    Thanks for the reply.

    My question is that if the library (say a.dll) is only for test project, how can I exclude it from the final built - I mean preventing add the a.dll to the final exe file Will excluding it from the final building list work


  • TheMadMonk

    Also, you have the configuration manager, which allows you to create a build configuration, and not include that assembly in the configuration, anyway, what jakeb says is right

  • _Michael_

    My question here is whether it is possible to build library used only for the unit testing

    Sure, I dont see why not, just build a regular .Net Class library and add it as a reference in the test project.

    Then all you have to do is add the using statement at the top and you can use all the public classes in that library.

    Coded Tests are just like writing programs in .Net they can use pretty much anything that .Net can do. (I have been working with coded web test but I am sure that unit tests should be able to do this same.)


  • meta_alucard

    Thanks. Got it.
  • Rui Dias VD

    sorry maybe I didn't got the question right, but, yes it's ok to create all of your unit test in a separate class library (Test project are just that), even more, this is the correct way to do it, so you isolate that assembly from the production code.

  • Is it possible to build library used only for the unit testing?