CppUnit. Cannot open file

  • From: "8Observer8" < >
  • To:
  • Subject: CppUnit. Cannot open file
  • Date: Wed, 10 Apr 2013 22:38:42 -0400

Hello everyone!

I created cppunit test for my simple class "Sphere"

But Error is occured: 
> d:/_____Work/sphere/tests/newtestclass.cpp:9:20: fatal error: Sphere.h: No 
> such file or directory


Sphere.h

Code:
/* 
 * File:   Sphere.h
 * Author: Ivan
 *
 * Created on April 11, 2013, 6:24 AM
 */

#ifndef SPHERE_H
#define SPHERE_H

class Sphere {
public:
    Sphere();
    double calcArea(double r);
    double calcVolume(double r);
private:
    double area;
    double volume;
};

#endif  /* SPHERE_H */



Shere.cpp

Code:
/* 
 * File:   Sphere.cpp
 * Author: Ivan
 * 
 * Created on April 11, 2013, 6:24 AM
 */

#include "Sphere.h"

Sphere::Sphere() {
    area = 0;
    volume = 0;
}

double Sphere::calcArea(double r) {
    return area;
}

double Sphere::calcVolume(double r) {
    return volume;
}



main.cpp
/
Code:

 * File:   main.cpp
 * Author: Ivan
 *
 * Created on April 11, 2013, 6:17 AM
 */

#include "Sphere.h"

int main(int argc, char** argv) {

    return 0;
}



newtestclass.cpp

Code:
/*
 * File:   newtestclass.cpp
 * Author: Ivan
 *
 * Created on Apr 11, 2013, 6:25:45 AM
 */

#include "newtestclass.h"
#include "Sphere.h"


CPPUNIT_TEST_SUITE_REGISTRATION(newtestclass);

newtestclass::newtestclass() {
}

newtestclass::~newtestclass() {
}

void newtestclass::setUp() {
}

void newtestclass::tearDown() {
}

void newtestclass::testCalcArea() {
    double r;
    Sphere sphere;
    double result = sphere.calcArea(r);
    if (true /*check result*/) {
        CPPUNIT_ASSERT(false);
    }
}

void newtestclass::testCalcVolume() {
    double r;
    Sphere sphere;
    double result = sphere.calcVolume(r);
    if (true /*check result*/) {
        CPPUNIT_ASSERT(false);
    }
}



newtestclass.h

Code:
/*
 * File:   newtestclass.h
 * Author: Ivan
 *
 * Created on Apr 11, 2013, 6:25:45 AM
 */

#ifndef NEWTESTCLASS_H
#define NEWTESTCLASS_H

#include <cppunit/extensions/HelperMacros.h>

class newtestclass : public CPPUNIT_NS::TestFixture {
    CPPUNIT_TEST_SUITE(newtestclass);

    CPPUNIT_TEST(testCalcArea);
    CPPUNIT_TEST(testCalcVolume);

    CPPUNIT_TEST_SUITE_END();

public:
    newtestclass();
    virtual ~newtestclass();
    void setUp();
    void tearDown();

private:
    void testCalcArea();
    void testCalcVolume();

};

#endif  /* NEWTESTCLASS_H */



newtestrunner.cpp

Code:
/*
 * File:   newtestrunner.cpp
 * Author: Ivan
 *
 * Created on Apr 11, 2013, 6:25:45 AM
 */

#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>

int main() {
    // Create the event manager and test controller
    CPPUNIT_NS::TestResult controller;

    // Add a listener that colllects test result
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener(&result);

    // Add a listener that print dots as test run.
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener(&progress);

    // Add the top suite to the test runner
    CPPUNIT_NS::TestRunner runner;
    runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
    runner.run(controller);

    // Print test in a compiler compatible format.
    CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
    outputter.write();

    return result.wasSuccessful() ? 0 : 1;
}




P.S. Sorry for my English






CppUnit. Cannot open file

8Observer8 04/11/2013

Project Features

About this Project

CND was started in November 2009, is owned by DimaZh, and has 131 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close