如何在使用量角器时运行单个特定的测试用例

时间:2021-12-04 01:24:21

I am using protractor for angular js testing in my app and have around 19 test cases at the moment, of which one of them is failing

我在我的应用程序中使用量角器进行角度js测试,目前有大约19个测试用例,其中一个失败

describe('Login page', function() {

beforeEach(function() {
  browser.ignoreSynchronization = true;
  ptor = protractor.getInstance();
});

it('should contain navigation items', function(){
  //test case code here
});

it('should login the user successfully', function(){ 
  //test case code here
})
});

Currently, I run all the test cases. But, how can I run just one test case to debug an issue for example one which is described as "Login page should login the user successfully"?

目前,我运行所有测试用例。但是,如何只运行一个测试用例来调试问题,例如一个被描述为“登录页面应该成功登录用户”的问题?

3 个解决方案

#1


26  

The most recent version (at least) of Protractor supports the usual Jasmine way of doing that: rename a describe() function to ddescribe(), and only the tests inside it will run. Or rename an it() function to iit(), and only this test will run.

Protractor的最新版本(至少)支持通常的Jasmine方式:将describe()函数重命名为ddescribe(),并且只有其中的测试才会运行。或者将it()函数重命名为iit(),并且只运行此测试。

#2


30  

Jasmine added fit and fdescribe in 2.1 for running single tests or describe blocks.

Jasmine在2.1中添加了适合和fdescribe用于运行单个测试或描述块。

http://pivotallabs.com/new-key-features-jasmine-2-1/

http://pivotallabs.com/new-key-features-jasmine-2-1/

This feature almost made it in the 2.0 release. Now enough of this functionality is present to support fit and fdescribe for focused spec and suite running.

此功能几乎在2.0版本中实现。现在,已经有足够的功能来支持精确和fdescribe的重点规范和套件运行。

from 2.1 git lib/jasmine-core/jasmine.js

来自2.1 git lib / jasmine-core / jasmine.js

var jasmineInterface = {
describe: function(description, specDefinitions) {
  return env.describe(description, specDefinitions);
},

xdescribe: function(description, specDefinitions) {
  return env.xdescribe(description, specDefinitions);
},

fdescribe: function(description, specDefinitions) {
  return env.fdescribe(description, specDefinitions);
},

it: function() {
  return env.it.apply(env, arguments);
},

xit: function() {
  return env.xit.apply(env, arguments);
},

fit: function() {
  return env.fit.apply(env, arguments);
},

#3


3  

Perhaps you should separate the tests into different suites. Then you can just run: protractor test/protractor-conf.js --suite example

也许您应该将测试分成不同的套件。然后你可以运行:量角器测试/ protractor-conf.js --suite示例

#1


26  

The most recent version (at least) of Protractor supports the usual Jasmine way of doing that: rename a describe() function to ddescribe(), and only the tests inside it will run. Or rename an it() function to iit(), and only this test will run.

Protractor的最新版本(至少)支持通常的Jasmine方式:将describe()函数重命名为ddescribe(),并且只有其中的测试才会运行。或者将it()函数重命名为iit(),并且只运行此测试。

#2


30  

Jasmine added fit and fdescribe in 2.1 for running single tests or describe blocks.

Jasmine在2.1中添加了适合和fdescribe用于运行单个测试或描述块。

http://pivotallabs.com/new-key-features-jasmine-2-1/

http://pivotallabs.com/new-key-features-jasmine-2-1/

This feature almost made it in the 2.0 release. Now enough of this functionality is present to support fit and fdescribe for focused spec and suite running.

此功能几乎在2.0版本中实现。现在,已经有足够的功能来支持精确和fdescribe的重点规范和套件运行。

from 2.1 git lib/jasmine-core/jasmine.js

来自2.1 git lib / jasmine-core / jasmine.js

var jasmineInterface = {
describe: function(description, specDefinitions) {
  return env.describe(description, specDefinitions);
},

xdescribe: function(description, specDefinitions) {
  return env.xdescribe(description, specDefinitions);
},

fdescribe: function(description, specDefinitions) {
  return env.fdescribe(description, specDefinitions);
},

it: function() {
  return env.it.apply(env, arguments);
},

xit: function() {
  return env.xit.apply(env, arguments);
},

fit: function() {
  return env.fit.apply(env, arguments);
},

#3


3  

Perhaps you should separate the tests into different suites. Then you can just run: protractor test/protractor-conf.js --suite example

也许您应该将测试分成不同的套件。然后你可以运行:量角器测试/ protractor-conf.js --suite示例