TA的每日心情 | 擦汗 昨天 09:07 |
---|
签到天数: 527 天 连续签到: 4 天 [LV.9]测试副司令
|
1测试积点
- <p>describe('Controllers: CheckListOverCtrl', function () {
- var $scope, ctrl, $httpBackend;</p><p> beforeEach(angular.mock.module('app.audit'));</p><p> beforeEach(angular.mock.inject(function ($rootScope, $controller, _$httpBackend_) {
- $httpBackend = _$httpBackend_;
- $httpBackend.when('GET','/Services/AuditWebForm.aspx/GetCheckListOver').
- respond([{ name: 'name1', ProjectName: "ProjectName1", I_Category: "I_Category1", uName: "uName1", dName: "dName1", D_Create: "D_Create1" },
- { name: 'name2', ProjectName: "ProjectName2", I_Category: "I_Category2", uName: "uName2", dName: "dName2", D_Create: "D_Create2" }]);</p><p> $scope = $rootScope.$new();
- ctrl = $controller('CheckListOverCtrl', { $scope: $scope });
- }));</p><p> it("标题测试", function () {
- expect($scope.$root.title).toBe('已审列表');
- });</p><p> it("取数据测试", function () {
- $httpBackend.flush();
- expect($scope.list.length).toBe(2);
- });
- });</p>
复制代码
这是测试代码。 想测试$scope.list 这样写错在哪里?
还有测试能写这种假返回值吗? 可以通讯后台方法吗? 要怎么写呢??
|
|