Menu

How to ensure that all asserts are evaluated

Help
Anonymous
2003-06-27
2003-06-28
  • Anonymous

    Anonymous - 2003-06-27

    I am writing testcase and in each testcase there are multiple asserts. I face problem that not all the asserst are tested. For example

    void testSample() {        CPPUNIT_ASSERT_EQUAL_MESSAGE("This test should fail",1050,1060);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(15.4,15.9,0.1);
    }

    I see when I run this test only the first assert is evaluated and second is not . What is the problem.

    Any help is highly appreciated

     
    • Tom Plunket

      Tom Plunket - 2003-06-27

      Put it into two tests if you want to ensure that all asserts are evaluated regardless of failing.

      Usually what I do is testSomeFunction, so all of the tests are surrounding the operation of SomeFunction.  What I get is testing up to the first failing assertion, but that's not a big problem because all assertions must pass for the test to be good, so I fix the first failure, and then if there are more failures I fix those as they come up.  Focusing on one failure at a time is definitely the way to go IMO.

       
    • ritesh

      ritesh - 2003-06-28

      Hi
      This the hows CppUnit work. The Assert whichever fails first, after that no assert is going to evaluate.
      Tom have already given the soultion for this.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.