Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 889777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:37:15+00:00 2026-05-15T13:37:15+00:00

I would like to specify the order of testing in CppUnit. According to my

  • 0

I would like to specify the order of testing in CppUnit. According to my research, the testing order depends on either the compiler or linker and how they came across the files.

How does one specify dependencies in CppUnit?

For example, let us consider a rectangle class that has four lines. Each line contains two point classes. Assume that each class is in a separate module or translation unit.

struct Point
{
  int x;
  int y;
};

struct Line
{
  Point a;
  Point b;
};

struct Rectangle
{
  Line top;
  Line left;
  Line right;
  Line bottom;
};

In the above code, the Point class should be tested first, then the Line class and finally the Rectangle class. There is no reason to test the Rectangle class if the Line or Point classes have problems. This is a very simplified example.

For composite classes, the inner classes or member data type classes should be test first.

Let us assume that each class has an associated testing class. Each test class has its own published test methods (which are registered to the CppUnit list), in separate files. The class for testing Lines has no knowledge of the testing class for points; and similar for the rectangle. When these test case classes are compiled, their order is dependent on the compiler and linker.

So, how does one order the test cases?

FYI, I am using CppUnit, wxTestRunner and Visual Studio 2008

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:37:16+00:00Added an answer on May 15, 2026 at 1:37 pm

    What you’re trying to do isn’t really unit testing. “Pure” unit testing is intended to test individual units (individual classes), using mocks or fake objects in the place of real dependencies; once you’re testing classes’ dependencies on each other, that’s integration testing, not unit testing.

    With that disclaimer out of the way…

    It looks like you might be able to use CPPUNIT_TEST_SUITE_NAMED_REGISTRATION to create multiple suites then run each suite in order, only if all previous suites have passed, but you might need to hack up or replace wxTestRunner test runner to do this.

    CppUnit’s page on Creating TestSuite has other options for registering test suites; CPPUNIT_REGISTRY_ADD, for example, lets you create a hierarchy of suites, which should give you some control over the ordering, but I don’t see any way for a failure in one suite to abort subsequent tests.

    Finally, just as a suggestion, CppUnit is probably not the best C++ unit testing framework these days. I’m personally a fan of Google Test, but Boost.Test and UnitTest++ are also good. (This answer introduces a personal project called Saru that sounds like it might give you the flexibility you want of ordering tests.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to specify the order of initialization of portlets when the portal
I would like to specify a default sort order in my model. So that
Hi would like to know how to specify a FetchRequest where i can order
I would like to specify that: :output_core depends on :build_core :build_extension depends on :build_core
I would like to specify that I want FEATURE_INDETERMINATE_PROGRESS for my Activity . It
I would like to specify JNDI name for an EJB3 bean using annotation, but
I'm using NUnit mocks and would like to specify that I expect a call
Hi GPUImage community and Brad, I would like to specify the filter size (radius)
Is it possible to specify a condition in Count() ? I would like to
I would like to dynamically specify the parent class for a class in Ruby.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.