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(){...}
}
我使用噶茉莉。