How to skip test cestception cest

I want to skip only one test in a cception test test.

Using Cept tests, you can do $scenario->skip(); but does not work for Cest tests.

So, I want to do something like this. Run the first test, but skip the second.

 Class MyTests{ public funtion test1(){ // My test steps } public function test2(){ $scenario->skip("Work in progress"); } } 

Thanks in advance.

+8
php testing skip codeception
source share
5 answers

the method you are looking for is called "incomplete".

$scenario->incomplete('your message, why skipping');

If you want to use scripts in Cest files, you can get it with the second parameter of your test method:

 class yourCest { public function yourTest(WebGuy $I, $scenario) { $scenario->incomplete('your message'); } } 

Or you can use $scenario->skip('your message')

 class yourCest { public function yourTest(WebGuy $I, $scenario) { $scenario->skip('your message'); } } 
+15
source share

I use skip annotation for my unit tests.

 /** * @skip */ public function MyTest(UnitTester $I) { ... } 
+12
source share

Use PHPUnit_Framework_SkippedTestError. For example:

  if (!extension_loaded('mongo')) { throw new \PHPUnit_Framework_SkippedTestError( 'Warning: mongo extension is not loaded' ); } 
+1
source share

First of all, remember which commands are available to you, will depend on which modules and kits you have downloaded. For example, if you are performing integration tests with WordPress YML enabled by default:

 $scenario->skip('your message'); 

will not work in Cest or Test out of the box, but will work in Acceptance.

In fact, as a rule, this command will work with Cept tests. [Cepts, usually such as tests, tests, and tests are usually PHPUnit, such as OOP tests]. In addition, you need to pass $ script to your function. This is clearly not documented, and I cannot get it to work in Cests. Don’t make me start by just how bad the "script $" choice is for the keyword for the BDD framework! "Script" is a keyword in Gherkin that refers to what is a "step object" in Codeception. In Codeception, it seems to be used as a redundant form of "environment", although there are already environments, suites and groups. Like most of these great frameworks, the names of documents and functions need to be redone by native English speakers for the second time! [remember "web guy"? Damn sexist Europeans! Lol].

If you use

 /** * @skip */ public function myTest(){ //this test is totally ignored } 

Annotations directly above your function in Cest or Test will be skipped and will not even appear in the report. [REALLY skip]. Use this if you want to completely hide the test.

If you use the PHPUnit command directly:

 public function myTest(){ throw new \PHPUnit_Framework_SkippedTestError('This test is skipped'); //this test will appear as a yellow "skipped" test in the report } 

This will result in a missed test in the report, turn yellow in the HTML report [--html]. Use this if you want to skip the test, but pay attention to the report that he missed.

+1
source share

So, so that your script skips during the test run:

  • You should have a $ script as the second input parameter in your test
  • make a call: $ script-> skip ();
  • make a call after skip: $ I-> comment ("Reason why the script missed")
0
source share

All Articles