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

  • Home
  • SEARCH
  • 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 508375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:54:02+00:00 2026-05-13T06:54:02+00:00

I am having a issue with boost unit testing. Basically I create a fixture

  • 0

I am having a issue with boost unit testing. Basically I create a fixture which is part of a suite to unit test a Resource cache. My main issue is between tests the Resource cache is becoming empty. So the first test that tests the cache passes then the second one will fail because the data the first test inserted into the cache is no longer there. To solve this I had to re insert the data for the second test. Is this intended or is it something I am doing wrong? Here is the code. The last 2 tests is where the issue lies.


#include "UnitTestIncludes.hpp"
#include "ResourceCache.hpp"
#include <SFML/Graphics.hpp>

struct ResourceCacheFixture
{
    ResourceCacheFixture()
    {
        BOOST_TEST_MESSAGE("Setup Fixture...");
        key = "graysqr";
        imgpath = "../images/graysqr.png";
    }

    ResourceCache<sf::Image, ImageGenerator> imgCache;
    std::string key;
    std::string imgpath;
};

// Start of Test Suite

BOOST_FIXTURE_TEST_SUITE(ResourceCacheTestSuite, ResourceCacheFixture)

// Start of tests

BOOST_AUTO_TEST_CASE(ImageGeneratorTest)
{
    ImageGenerator imgGen;
    BOOST_REQUIRE(imgGen("../images/graysqr.png"));

}

BOOST_AUTO_TEST_CASE(FontGeneratorTest)
{
    FontGenerator fntGen;
    BOOST_REQUIRE(fntGen("../fonts/arial.ttf"));
}

// This is where the issue is.  The data inserted in this test is lost for when I do
// the GetResourceTest.  It is fixed here by reinserting the data.
BOOST_AUTO_TEST_CASE(LoadResourceTest)
{
    bool result = imgCache.load_resource(key, imgpath);
    BOOST_REQUIRE(result);
}

BOOST_AUTO_TEST_CASE(GetResourceTest)
{
    imgCache.load_resource(key, imgpath);
    BOOST_REQUIRE(imgCache.get_resource(key));
}

// End of Tests

// End of Test Suite
BOOST_AUTO_TEST_SUITE_END()
  • 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-13T06:54:03+00:00Added an answer on May 13, 2026 at 6:54 am

    It is intended. One of the key principles of unit testing is that every test is run in isolation. It should be given a clean environment in which to run, and that environment should be cleaned up again afterwards, so that tests do not depend on each others.

    With Boost.Test, you can specify which tests to run from the commandline, so you don’t have to run the entire suite. If your tests depend on each others, or on the order in which they’re executed, then this would cause tests to fail.

    Fixtures are intended to set up the environment you need to run the test. If you need resources to be created before the test runs, the fixture should create them, and clean them up again afterwards.

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

Sidebar

Ask A Question

Stats

  • Questions 261k
  • Answers 261k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you need to change your if statement to:… May 13, 2026 at 11:34 am
  • Editorial Team
    Editorial Team added an answer maybe needs to set the application-wide cursor as well Mouse.OverrideCursor… May 13, 2026 at 11:34 am
  • Editorial Team
    Editorial Team added an answer Take a look at this link and see if it… May 13, 2026 at 11:34 am

Related Questions

I'm learning Boost and am having trouble with my makes files. Here is my
I'm just getting started with Boost for the first time, details: I'm using Visual
RESOLVED After much confusion and frustration, I finally got my hard disk to interrupt.
I need to process a HTML content and replace the IMG SRC value with
I have created an MS Access 2003 application, set up as a split front-end/back-end

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.