Angularjs 使用jasmine/karma的Angular factory单元测试用例
我对Angular有很好的理解,但是从来没有为Angular代码编写过任何测试用例,因此对工厂需要编写什么样的测试用例以及如何编写测试用例的理解很少。我已经安装了karma/nodejs,能够运行基本单元测试。请帮助编写以下测试用例 工厂使用$resourceAngularjs 使用jasmine/karma的Angular factory单元测试用例,angularjs,jasmine,karma-runner,angular-resource,Angularjs,Jasmine,Karma Runner,Angular Resource,我对Angular有很好的理解,但是从来没有为Angular代码编写过任何测试用例,因此对工厂需要编写什么样的测试用例以及如何编写测试用例的理解很少。我已经安装了karma/nodejs,能够运行基本单元测试。请帮助编写以下测试用例 工厂使用$resource //create User factory app.factory('User', ['$resource', function($resource) { return $resource('/users/:id', {i
//create User factory
app.factory('User', ['$resource', function($resource) {
return $resource('/users/:id', {id: '@id'}, {update: {method: 'PUT', isArray: false}});
}]);
关于测试用例,我有以下问题
1. $resource make server call. Not sure if Karma/jasmin will be able to make server call.
2. I want to write test case in following order
a. Create new user and fetch the _id from response
b. Get list of all users and get the user details for #a _id.
c. Match the details used in #a and details returned by #b
d. Update some details of user using "update" and repeat #b and #c.
e. Delete user and perform step $b to make sure that user object is deleted.
请帮忙。你读过这些吗?然后,您就可以开始使用一个小型测试用例。当你有非常具体的问题时,请回来。现在你没有。