naz1719
naz1719

Reputation: 3

PublishCucumberReport - Can't find output path of cucumber report

The plugin can't find files and generate HTML report on Azure DevOps

Azure Devops plugin - https://marketplace.visualstudio.com/items?itemName=MaciejMaciejewski.azure-pipelines-cucumber

azure-pipelines.yml

jobs:
  # Build Electron
  - job: UserAcceptanceTest
    displayName: E2E-Tests
    pool:
      name: ado-win-pool
    timeoutInMinutes: 120
    steps:
      - task: CopyFiles@2
        inputs:
          sourceFolder: $(Build.SourcesDirectory)
          targetFolder: $(Build.ArtifactStagingDirectory)

      - task: PublishPipelineArtifact@1
        displayName: 'Publishing build artifacts'
        inputs:
          targetPath: $(Build.ArtifactStagingDirectory)

      - task: NodeTool@0
        displayName: 'Install Node 12.x'
        inputs:
          versionSpec: 12.x

      - task: PublishCucumberReport@1
        displayName: 'Publish Cucumber Report'
        inputs:
          jsonDir: target/results/cucumber/
          outputPath: target/results/cucumber/

Actual:

  Found 0 matching C:/agent/_work/13/s/target/results/cucumber pattern
    ##[warning]Error: Not found outputPath: C:\agent\_work\13\s\target\results\cucumber
    Finishing: Publish Cucumber Report

Expected: Found cucumber JSON file.

Upvotes: 0

Views: 5150

Answers (2)

Kateryna Lysenko
Kateryna Lysenko

Reputation: 26

In your case, the problem is in the path provided for the cucumber report. It should be a path to the folder with cucumber reports in json format, but not to some particular json.

So, the correct snippet in yaml would be:

        - task: PublishCucumberReport@1
        displayName: 'Publish Cucumber Report'
        inputs:
        jsonDir: target/results/cucumber/
        outputPath: target/results/cucumber/

Upvotes: 1

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30313

In above yaml pipeline, you didnot have the step to run your cucumber test to generate the cucumber JSON file.

If the cucumber JSON file is already existing in your repo. Then the error from PublishCucumberReport task is because the directory target/results/cucumber doesnot exist in your repo.

Then You need to check where the cucumber JSON file is located in your repo and specify the correct path for PublishCucumberReport task.

If there is no cucumber JSON fileexisting in your repo. You should add steps in the yaml pipeline to run your tests.

If you have your test scripts configured in the package.json file, like below(report folder must exist in the repo):

enter image description here

You can just run the npm test to execute your tests and generate the json report in the report folder. See below;

steps:
- task: NodeTool@0
  displayName: 'Install Node 12.x'
  inputs:
    versionSpec: 12.x

- script: |
   npm install
   npm test
  displayName: 'Run tests'
 

- task: PublishCucumberReport@1
  inputs:
    jsonDir: report
    outputPath: report

If there is no test script defined in your package.json file. You can run the cucumber-js command in the yaml pipeline to generate the json file. See below:

- script: |
   #npm install cucumber
   npm install 
   ./node_modules/.bin/cucumber-js features -f json:report/cucumber_report.json
  displayName: 'Run tests'

Upvotes: 1

Related Questions