Backbone和Jasmine - 单元测试的上下文

时间:2014-02-10 13:01:14

标签: unit-testing backbone.js jasmine bdd

假设我有一个桌面排的单位,其中包含一些在联赛中打球的篮球队(比赛,赢了,输了等)的详细信息。

现在我想编写单元测试。

以下哪种方法更好的用例

方法1:技术

将单位视为表格行。

describe("Given a table row", function(){
    describe("When I remove it from the table", function(){
        ...
    });
});

方法2:实用

将该单位视为篮球队。

describe("Given a basketball team", function(){
    describe("When I remove it from the league", function(){
        ...
    });
});

1 个答案:

答案 0 :(得分:2)

您的测试语言应与您的类位于同一个域中。

换句话说,方法2是最好的,因为在Behavior Driven Development意义上,你表达了行为。

您还应该尝试在验收测试中使用类似用户故事的语言。

When a Coach removes it from the league

相关问题