Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to use "UnitTest" to test C++ code [modified]

How to use "UnitTest" to test C++ code [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cold_Fearing_Bird
    wrote on last edited by
    #1

    "UnitTest" is on the VC's main menu,I want to use itto test my C++ code, but I am not familiar with its mechanism. I wrote a little code expecting to learn how it works.But seems not work. here's my code

    class myClass
    {
    private:
    int m_i ;
    public:
    myClass( int i ):m_i(i){ }
    BOOL EQ( int i )
    {
    if( m_i == i )
    return TRUE ;
    else
    return FALSE ;
    }
    } ;

    int main()
    {
    myClass mc( 10 ) ;
    }

    I click "new UnitTest", go through a few steps,when trying click the checkbox besides my project name, there's always a msg reporting unsuccessful "Unknown virtual address 0". Waiting for help...

    modified on Thursday, July 21, 2011 5:09 AM

    _ R 2 Replies Last reply
    0
    • C Cold_Fearing_Bird

      "UnitTest" is on the VC's main menu,I want to use itto test my C++ code, but I am not familiar with its mechanism. I wrote a little code expecting to learn how it works.But seems not work. here's my code

      class myClass
      {
      private:
      int m_i ;
      public:
      myClass( int i ):m_i(i){ }
      BOOL EQ( int i )
      {
      if( m_i == i )
      return TRUE ;
      else
      return FALSE ;
      }
      } ;

      int main()
      {
      myClass mc( 10 ) ;
      }

      I click "new UnitTest", go through a few steps,when trying click the checkbox besides my project name, there's always a msg reporting unsuccessful "Unknown virtual address 0". Waiting for help...

      modified on Thursday, July 21, 2011 5:09 AM

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      I haven't used the tool myself, but isn't there a startup guide to make us understanding the procedure to be followed. Also, you can refer the articles on MSDN and I sure you will find more than one that will guide you further.

      You talk about Being HUMAN. I have it in my name AnsHUMAN

      S 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        I haven't used the tool myself, but isn't there a startup guide to make us understanding the procedure to be followed. Also, you can refer the articles on MSDN and I sure you will find more than one that will guide you further.

        You talk about Being HUMAN. I have it in my name AnsHUMAN

        S Offline
        S Offline
        Stefan_Lang
        wrote on last edited by
        #3

        Certainly good advice, but I have to say it may not be easy to find useful material: I've faced almost the same problem, and my searches turned up tons of Tools for Unit-Testing or Tutorials for using such tools, but virtually nothing about how to set up a unit test in the first place! :( Maybe an explicit search at specific sites such as MSDN or various technical forums might help - I haven't tried that yet.

        C 1 Reply Last reply
        0
        • S Stefan_Lang

          Certainly good advice, but I have to say it may not be easy to find useful material: I've faced almost the same problem, and my searches turned up tons of Tools for Unit-Testing or Tutorials for using such tools, but virtually nothing about how to set up a unit test in the first place! :( Maybe an explicit search at specific sites such as MSDN or various technical forums might help - I haven't tried that yet.

          C Offline
          C Offline
          Cold_Fearing_Bird
          wrote on last edited by
          #4

          Yeah, I searched lot, still haven't found too much helpful materials.I think I should give up using it since it related tightly with netFramework.Someone says C++ test is one of the best UnitTest tool, I'll have a try.

          S 1 Reply Last reply
          0
          • C Cold_Fearing_Bird

            Yeah, I searched lot, still haven't found too much helpful materials.I think I should give up using it since it related tightly with netFramework.Someone says C++ test is one of the best UnitTest tool, I'll have a try.

            S Offline
            S Offline
            Stefan_Lang
            wrote on last edited by
            #5

            Indeed. I've been spending the last hour to find something more useful, and have all but given up. At the moment I'm digesting the entries on Unit testing that I've found on Wikipedia, just to be make sure I fully understand the concepts. Maybe that's a good place for you to look too? Unit Testing - Wikipedia

            C 1 Reply Last reply
            0
            • S Stefan_Lang

              Indeed. I've been spending the last hour to find something more useful, and have all but given up. At the moment I'm digesting the entries on Unit testing that I've found on Wikipedia, just to be make sure I fully understand the concepts. Maybe that's a good place for you to look too? Unit Testing - Wikipedia

              C Offline
              C Offline
              Cold_Fearing_Bird
              wrote on last edited by
              #6

              Thanks, Stefan. I'll take a look.I love Wiki too. It was the place that taught me how to do the matrix multiplication.Hoho :)

              1 Reply Last reply
              0
              • C Cold_Fearing_Bird

                "UnitTest" is on the VC's main menu,I want to use itto test my C++ code, but I am not familiar with its mechanism. I wrote a little code expecting to learn how it works.But seems not work. here's my code

                class myClass
                {
                private:
                int m_i ;
                public:
                myClass( int i ):m_i(i){ }
                BOOL EQ( int i )
                {
                if( m_i == i )
                return TRUE ;
                else
                return FALSE ;
                }
                } ;

                int main()
                {
                myClass mc( 10 ) ;
                }

                I click "new UnitTest", go through a few steps,when trying click the checkbox besides my project name, there's always a msg reporting unsuccessful "Unknown virtual address 0". Waiting for help...

                modified on Thursday, July 21, 2011 5:09 AM

                R Offline
                R Offline
                Rolf Kristensen
                wrote on last edited by
                #7

                This might help: Unit-Testing Native C++ with Visual Studio[^] By using the Unit Testing framework in Visual Studio, then you should automatically get the ability to see code coverage (Though it requires one of the expensive Visual Studio Editions)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups