Acccess Project/Workspace Location in cpptest suite

SixDegreesSixDegrees 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

  • MichaelCMichaelC Posts: 22 admin

    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.

Sign In or Register to comment.