Skip to content

Latest commit

 

History

History
102 lines (70 loc) · 5.23 KB

File metadata and controls

102 lines (70 loc) · 5.23 KB

Unity.AutoUI Testing Project

This project uses a Cypress folder structure to automate end-to-end testing for the Unity Grant Manager application. The Cypress testing framework executes automated tests to ensure the quality and reliability of the web application using continuous integration.

Subfolders and Files

  • cypress/: Cypress configuration and test files.
  • cypress.config.ts: Cypress configuration in TypeScript.
  • cypress.pipeline.env.json: CI/CD environment overrides.
  • package.json, package-lock.json: Project dependencies and metadata.
  • tsconfig.json: TypeScript configuration.

See the README for setup and usage instructions.

Getting Started

To get started with this Cypress project, follow these steps:

  1. Prerequisites: Install Node.js & npm.
  2. Installation: npm install cypress typescript downloads Cypress and dependencies to a node_modules subdirectory.
  3. Configuration: Set up a Cypress typescript configuration file (cypress.config.ts).
  4. Writing Tests: Create test scenarios within the cypress/e2e directory.
  5. Executing Tests: npx cypress run to execute Cypress tests in headless mode.

Project Structure

The Cypress projects typically have a directory structure as follows:

  • cypress/: Cypress configuration and test files.
    • e2e/: End-to-end test files specifically targeting the application's functionality.
      • testcasefiles.cy.ts: End-to-end test specifications written in Cypress testing syntax.
    • fixtures/: Files used to mock data for testing.
    • integration/: Standalone tests written in Cypress testing syntax.
    • plugins/: Plugins used to extend Cypress's functionality.
    • support/: Commands and custom Cypress configurations.
      • e2e.ts: Functions specifically for end-to-end testing.
      • commands.ts: Custom Cypress commands used in end-to-end testing.
  • node_modules: Automatically generated folder for the Node.js modules and dependencies.
  • cypress.config.ts: Configuration settings for Cypress, written in TypeScript format.
  • cypress.env.json : Cypress environmental variables (Ignored in repository).
  • cypress.pipeline.env.json : CI/CD file used to override cypress.env.json variables.
  • package.json: Project dependencies and metadata.
  • package-lock.json: Automatically generated where npm modifies either the node_modules tree or package.json file.
  • tsconfig.json: TypeScript transpiler configuration settings for the project.

The e2e/ folder is where you'll find test files that cover the end-to-end scenarios of the web application. These tests typically simulate user interactions with the application's UI to ensure that all components and features are working correctly.

Configuration Options

The cypress.config.ts file allows customization of Cypress's behavior. Refer to the Cypress documentation for available configuration options.

Build and Test

To build and test the Cypress project using Azure DevOps and a Git repo, follow these steps:

  1. Source Repository: A Git repository branch containing the expected Cypress project files.
  2. Build Pipeline: Used to include project dependencies, execute token substitutions, and generate artifacts containing the end-to-end Cypress test directories.
  3. Release Pipeline: The release pipeline in Azure DevOps will deploy the published build artifact to one of the available build agents and further refine token substitutions based on the specific stage under test.
  4. Executing Tests: Execute headless Cypress tests as part of the deployment process on the build agent server.
  5. Viewing Results: After deployment, view test results and logs generated by Cypress on the build agent server.

These steps describe the build, deployment, and test run of a Cypress project using Azure DevOps.

Continuous Integration

The Cypress tests are integrated into the Azure DevOps CI/CD pipeline using Azure Pipelines. The CI/CD configuration includes trigger conditions, parallel execution, and other relevant settings defined in the Azure Pipelines.

Token Replacement

Pipeline Release Task: Replace tokens in text based files:

  with:
    tokenPrefix: '{{'
    tokenSuffix: '}}'
    folder: $(System.DefaultWorkingDirectory)/$(Artifact)/TestRunner
    files: '["**/*.ts"]'

Reporting

Test results and logs generated by Cypress are collected and reported using reporting tools integrated into the Azure DevOps pipeline.

Best Practices

Follow these best practices for writing efficient and maintainable Cypress tests:

  • Use page objects to encapsulate page-specific functionality and selectors.
  • Organize tests into logical suites based on functionality or user journeys.
  • Use descriptive test names and comments to improve readability and maintainability.

Contributing Guidelines

Contributions to this project are welcome! Follow these guidelines when contributing:

  • Report issues using Azure work items, providing clear and concise details.
  • Submit pull requests with descriptive titles and a clear explanation of the proposed changes.
  • Adhere to the coding standards and conventions used in the project.

License

This project is licensed under the terms of the MIT license.