1
我有一大堆的服務,如:呼叫茉莉花測試對象的不同
function ServiceA() {}
ServiceA.name = "Service A";
ServiceA.description = "A service called A";
ServiceA.doStuff = new function(inputString){...});
說:
- 都必須具有相同的屬性設置(名稱,描述)
- 都有一個名稱相同的方法,但每種服務的方法內容都不相同。
目前我有一個單獨的測試每個服務,檢查屬性和方法的結果。但隨着測試/事測試對於每一個服務是相同的,我不知道如果我可以做這樣的事情:
var services = [ServiceA, ServiceB, ServiceC];
for (index = 0; index < services.length; index++) {
describe("Testing Service", testFunction(services[index]));
}
function testFunction(service){
it("bla", function(){...}
}
我使用噶茉莉。