Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Acccess Project/Workspace Location in cpptest suite

Options
SixDegrees
SixDegrees Posts: 2

Our current test suite is littered with absolute file paths. This makes our test suites less portable. I'd like to be able to access the workspace and project locations from within our tests. How can I do this? Are there environment variables that contain this information that can be gotten through getenv()? Or are there other methods?

Answers

  • MichaelC
    MichaelC Posts: 28 admin
    Options

    Hello @SixDegrees,

    I am a little confused by this post. If you're auto-generating Unit Tests and/or Test Suites, C++test will set paths relative to the project location rather than an absolute path.

    For example,

    Auto-generating the test suite for the ATM project would look something like this in the source code.

    BaseDisplay.cxx Auto-generated Test Suite:
    CPPTEST_CONTEXT("/ATM/ATM/BaseDisplay.cxx")
    CPPTEST_TEST_SUITE_INCLUDED_TO("/ATM/ATM/BaseDisplay.cxx")

    The absolute file location of this file on my machine is /home/user/cpptest/10.4/examples/ATM/BaseDisplay.cxx

    Please correct me if I am mistaken about your current issue. If you can provide a small example regarding this behavior I should be able to provide more guidance.