搜索

PythonReactSEOPDF
GitHub Skill

allure-reporting

Guide for working with Allure test reporting in this Cucumber project. Use this when asked about test reports, adding annotations, or improving test documentation.

RubenDguez☆ 0 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Allure Reporting Guide

This project uses Allure for test reporting. Here's how to effectively work with Allure features:

Basic Allure Commands

# Generate and open reports
npm run allure:generate  # Generate report from test results
npm run allure:open      # Open report in browser
npm run allure           # Generate and open in one command

Enhancing Test Reports

1. Adding Descriptions and Annotations
import { Given, Then, When } from '@cucumber/cucumber';
import { allure } from 'allure-cucumberjs/reporter';

Given('I am on the Salesforce website', async function (this: Fixture) {
  await allure.epic('Authentication');
  await allure.feature('Login');
  await allure.story('User Login');
  await allure.severity('critical');
  
  await this.loginPage.navigate();
});
2. Adding Steps and Attachments
When('I enter valid credentials', async function (this: Fixture) {
  await allure.step('Entering username', async () => {
    const username = process.env.SF_USERNAME || '';
    await this.loginPage.enterUsername(username);
  });

  await allure.step('Entering password', async () => {
    const password = process.env.SF_PASSWORD || '';
    await this.loginPage.enterPassword(password);
  });

  // Add screenshot for documentation
  const screenshot = await this.page.screenshot({ fullPage: true });
  await allure.attachment('Login Form Screenshot', screenshot, 'image/png');
});
3. Feature File Annotations
Feature: Login
  As a user I should be able to login into Salesforce
  
  @critical @smoke
  Scenario: Successful Login
    Given I am on the Salesforce website
    When I enter valid credentials
    Then I should be logged in successfully
    
  @negative @regression  
  Scenario: Failed Login with Invalid Credentials
    Given I am on the Salesforce website
    When I enter invalid credentials
    Then I should see an error message
4. Adding Test Links and Documentation
Then('I should be logged in successfully', async function (this: Fixture) {
  await allure.link('Test Case', 'https://your-test-management-tool.com/test-123');
  await allure.link('Bug Report', 'https://your-issue-tracker.com/bug-456', 'issue');
  
  const isLoggedIn = await this.loginPage.isLoggedIn();
  
  if (!isLoggedIn) {
    // Add failure context
    const screenshot = await this.page.screenshot({ fullPage: true });
    await allure.attachment('Failure Screenshot', screenshot, 'image/png');
    
    const pageSource = await this.page.content();
    await allure.attachment('Page Source', pageSource, 'text/html');
  }
  
  expect(isLoggedIn).toBe(true);
});

Report Organization

1. Cucumber Configuration for Allure
// In cucumber.mjs
export default {
  // ... other config
  format: ['allure-cucumberjs/reporter'],
  formatOptions: {
    resultsDir: 'allure-results',
    labels: [
      {
        pattern: [/@feature:(.*)/],
        name: 'feature'
      },
      {
        pattern: [/@severity:(.*)/],
        name: 'severity'
      }
    ],
    links: [
      {
        pattern: [/@link:(.*)/],
        type: 'link'
      }
    ]
  }
};
2. Environment Information
// In support/hooks.ts
import { BeforeAll, AfterAll } from '@cucumber/cucumber';
import { allure } from 'allure-cucumberjs/reporter';

BeforeAll(async function () {
  await allure.writeEnvironmentInfo({
    'Test Environment': process.env.TEST_ENV || 'development',
    'Browser': 'Chromium',
    'Base URL': process.env.SF_BASE_URL || 'default-url',
    'Playwright Version': require('@playwright/test/package.json').version,
    'Node Version': process.version,
    'OS': process.platform
  });
});

Advanced Allure Features

1. Custom Categories for Failures
// Create allure-results/categories.json
[
  {
    "name": "Authentication Failures",
    "matchedStatuses": ["failed"],
    "messageRegex": ".*login.*|.*authentication.*|.*credentials.*"
  },
  {
    "name": "Network Issues",
    "matchedStatuses": ["broken"],
    "messageRegex": ".*timeout.*|.*network.*|.*connection.*"
  },
  {
    "name": "Environment Issues",
    "matchedStatuses": ["failed"],
    "messageRegex": ".*SF_USERNAME.*|.*SF_PASSWORD.*|.*environment.*"
  }
]
2. Test Data Attachments
// In step definitions
When('I use test data {string}', async function (this: Fixture, dataSet: string) {
  const testData = TestData.getDataSet(dataSet);
  
  // Attach test data for reference
  await allure.attachment(
    'Test Data Used', 
    JSON.stringify(testData, null, 2), 
    'application/json'
  );
  
  // Use the test data...
});
3. Performance Monitoring
// Add timing information
Then('the page should load quickly', async function (this: Fixture) {
  const startTime = Date.now();
  
  await this.page.waitForLoadState('networkidle');
  
  const loadTime = Date.now() - startTime;
  
  await allure.parameter('Load Time (ms)', loadTime.toString());
  await allure.step(`Page loaded in ${loadTime}ms`, () => {});
  
  expect(loadTime).toBeLessThan(5000); // 5 second threshold
});

Report Best Practices

  1. Consistent Tagging: Use consistent tags across features for better filtering
  2. Meaningful Screenshots: Take screenshots at key points, not just failures
  3. Detailed Steps: Break down complex actions into smaller, reportable steps
  4. Environment Context: Always include relevant environment information
  5. Failure Context: Provide comprehensive failure information (screenshots, logs, page state)
  6. Performance Data: Include timing information for critical operations
  7. Traceability: Link tests to requirements or bug reports where applicable

Viewing Reports

  • Open the generated report in your browser
  • Use filters to view specific test categories
  • Review failure trends and patterns
  • Export results for CI/CD integration
  • Share reports with team members for collaboration

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!