English 中文(简体)
功能测试
原标题:functional testing a service

我在申请中曾尝试过一些简单的服务。 这是我的服务方法:

public function createNewCourse($details = array())
    {
        $course = new Course($details);
        $this->persistenceManager->save($course);
    }

基本上,我向这一部门派出一个阵列,创建确定物体特性的汇合物。 在此之后,我称之为持久性管理,它基本上有一种节省的方法,在数据库中添加该物体。 任何在不实际测试持久性的情况下如何测试这种方法的倾向,因为这将是另一个考验。

问题回答

injected to their Object as a Dependancy,那么,您可创建rel=“nofollow”>m Objectock,在你的测试中代表它。

如果没有,那么,你就很难进行单位测试,你应当重新证明你的代码是使用依赖性注射。

Don,依赖性注射只是一种简单概念的缩略语。

你们将面临同样的问题,即检查课程对象。

采用一种顽固不变的做法,并将其提供给包含create NewCourse方法的类别。 不要忘记:

class StubPersistenceManager
{
    private $course;
    public function save($course)
    {
         $this->course = $course;
    }
    public function getCourse()
    {
         return $this->course;
    }
}

确保你把这个 st块列为“thi”, 页: 1

在测试中,你采用create NewCourse方法,然后通过使用“getCourse功能向顽固管理人员提供课程。





相关问题
run unit tests and coverage in certain python structure

I have some funny noob problem. I try to run unit tests from commandline: H:PROpyEstimator>python src estpython est_power_estimator.py Traceback (most recent call last): File "src est...

How to unit-test an enterprise symfony project?

I´m working on a huge project at my work. We have about 200 database tables, accordingly a huge number of Models, Actions and so on. How should I begin to write tests for this? My biggest problem ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Unit testing. File structure

I have a C++ legacy codebase with 10-15 applications, all sharing several components. While setting up unittests for both shared components and for applications themselves, I was wondering if there ...

Unit Testing .NET 3.5 projects using MStest in VS2010

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...

热门标签