This repository was archived by the owner on Dec 18, 2019. It is now read-only.
  
  
  - 
                Notifications
    You must be signed in to change notification settings 
- Fork 58
Split pending and skipped tests #34
          
     Open
      
      
            just-boris
  wants to merge
  2
  commits into
  webdriverio-boneyard:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
just-boris:master
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| var assert = require('assert') | ||
|  | ||
| module.exports = function () { | ||
| this.Given(/Test will fail/, (url) => { | ||
| return assert.ok(false, 'expected failure') | ||
| }) | ||
|  | ||
| this.Given('Pending test', () => 'pending') | ||
|  | ||
| this.Then(/this step will be skipped/, (selector) => { | ||
| throw new Error('unexpected error') | ||
| }) | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export default { | ||
| sync: false, | ||
| capabilities: { | ||
| browserName: 'chrome' | ||
| }, | ||
|  | ||
| cucumberOpts: { | ||
| timeout: 5000, | ||
| require: [__dirname + '/steps-status-step-definitions.js'] | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Feature: Steps status | ||
|  | ||
| Scenario: Failing test | ||
| Given Test will fail | ||
| And this step will be skipped | ||
| Then this step will be skipped | ||
|  | ||
| Scenario: Pending | ||
| Given Pending test | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { CucumberAdapter } from '../lib/adapter' | ||
| import CucumberReporter from '../lib/reporter' | ||
| import config from './fixtures/steps-status.conf' | ||
|  | ||
| const specs = ['./test/fixtures/steps-status.feature'] | ||
|  | ||
| const WebdriverIO = class {} | ||
|  | ||
| describe('steps', () => { | ||
| it('should report different status for steps', async () => { | ||
| const messages = [] | ||
| const send = CucumberReporter.prototype.send | ||
| CucumberReporter.prototype.send = message => messages.push(message) | ||
| global.browser = new WebdriverIO() | ||
| global.browser.options = config | ||
| const adapter = new CucumberAdapter(0, config, specs, {}) | ||
|  | ||
| ;(await adapter.run()).should.be.equal(1) | ||
|  | ||
| messages.map(msg => msg.event).should.be.deepEqual([ | ||
| 'suite:start', | ||
|  | ||
| // failed | ||
| 'suite:start', | ||
| 'test:start', | ||
| 'test:fail', | ||
| 'test:start', | ||
| 'test:skipped', | ||
| 'test:start', | ||
| 'test:skipped', | ||
| 'suite:end', | ||
|  | ||
| // pending | ||
| 'suite:start', | ||
| 'test:start', | ||
| 'test:skipped', | ||
| 'suite:end', | ||
|  | ||
| 'suite:end' | ||
| ]) | ||
|  | ||
| CucumberReporter.prototype.send = send | ||
| }) | ||
| }) | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@just-boris I still don't know why we change the event name here, can't we handle this in the allure reporter only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to this change, pending, skipped and ambiguous tests are still treated equally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of this change is normalizing behavior of Cucumber with other frameworks.
Neither Mocha nor Jasmine doesn't emit
test:startfor pending tests.I tried to cancel
test:startevent for pending test, but Cucumber API is designed in a way that doesn't let us know about pending test in advance.This is why I came up with the current solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the base reporter does not trigger if the event name is
skipped, see https://github.com/webdriverio/webdriverio/blob/master/lib/utils/BaseReporter.js#L114There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the allure reporter is the only reporter that has problems with it why not just fixing it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a valid point, but then here is a different problem.
Mocha framework doesn't fire
test:startevent for pending tests, but Cucumber does.Allure is the only reporter that suffers from it just because it is the only reporter from the standard set, that uses this event, but there is a general problem in inconsistency, that I am trying to mitigate.