https://github.com/phmatray/autotests
Automated E2E testing demo for Blazor using Reqnroll, showcasing BDD acceptance tests with Gherkin syntax and Playwright .NET
https://github.com/phmatray/autotests
blazor csharp demo dotnet e2e gherkin nunit playwright reqnroll testing
Last synced: 26 days ago
JSON representation
Automated E2E testing demo for Blazor using Reqnroll, showcasing BDD acceptance tests with Gherkin syntax and Playwright .NET
- Host: GitHub
- URL: https://github.com/phmatray/autotests
- Owner: phmatray
- Created: 2025-04-03T14:37:21.000Z (about 1 year ago)
- Default Branch: dev
- Last Pushed: 2026-04-18T11:48:44.000Z (about 2 months ago)
- Last Synced: 2026-04-18T13:26:39.678Z (about 2 months ago)
- Topics: blazor, csharp, demo, dotnet, e2e, gherkin, nunit, playwright, reqnroll, testing
- Language: C#
- Homepage:
- Size: 56.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ticket Booking Demo Project ποΈ
This repository demonstrates **Automated E2E Testing for Blazor using Reqnroll**. It showcases a simple ticket booking system with acceptance tests written in Gherkin syntax and executed with Playwright .NET.
---
## Table of Contents
- [Features π](#features-)
- [Prerequisites βοΈ](#prerequisites-)
- [Getting Started π§](#getting-started-)
- [Running the Application π](#running-the-application-)
- [Running the Tests π§ͺ](#running-the-tests-)
- [Project Structure π](#project-structure-)
- [Contributing π€](#contributing-)
- [License π](#license-)
---
## Features π
- **Event Listing:** Displays a list of upcoming events.
- **Event Details:** Shows detailed information for each event.
- **Ticket Booking:** Allows users to book tickets by entering their name.
- **Automated Acceptance Tests:** Validates key user flows using Gherkin-based specifications with Reqnroll and Playwright .NET.
---
## Prerequisites βοΈ
- [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0) or later
---
## Getting Started π§
1. **Clone the Repository**
```bash
git clone https://github.com/phmatray/AutoTests.git
cd AutoTests
```
2. **Restore .NET Packages**
From the solution directory, run:
```bash
dotnet restore
```
3. **Install Playwright Browsers**
Navigate to the test project directory and install the required browsers:
```bash
cd TicketBookingApp.EndToEndTests
pwsh bin/Debug/net9.0/playwright.ps1 install
```
4**Project Configuration**
The test project uses the following `csproj` configuration:
```xml
net9.0
```
---
## Running the Application π
1. **Navigate to the Blazor Project Directory**
```bash
cd TicketBookingApp
```
2. **Run the Blazor Server Application**
```bash
dotnet run
```
3. **Access the Application**
Open your browser and navigate to `http://localhost:5140/` (or the URL provided by your console) to view the ticket booking system.
---
## Running the Tests π§ͺ
1. **Ensure the Blazor Application Is Running**
Start the Blazor app as described above.
2. **Navigate to the Test Project Directory**
```bash
cd TicketBookingApp.EndToEndTests
```
3. **Run the Test Suite**
```bash
dotnet test
```
The acceptance tests are written in Gherkin and located in the `/features` folder. Hereβs an example of the feature file:
```gherkin
Feature: Ticket Booking System
As a user,
I want to view available events and book tickets,
So that I can attend an event.
Scenario: Home page lists available events
Given I navigate to the home page
Then I should see a list of events
Scenario: Event details are displayed correctly
Given I navigate to the event details page for event with id 1
Then I should see the event title "Rock Concert"
Scenario: Booking a ticket successfully
Given I navigate to the booking page for event with id 1
When I enter "John Doe" into the "User Name" field
And I click on "Confirm Booking"
Then I should see a confirmation message "Booking Confirmed"
```
---
## Project Structure π
```
/TicketBookingApp
βββ Models/ // Data models (e.g., Event.cs)
βββ Pages/ // Blazor pages (Index.razor, EventDetails.razor, Booking.razor)
βββ Services/ // Application services (e.g., EventService.cs)
βββ Program.cs // Application entry point
/TicketBookingApp.EndToEndTests
βββ Features/ // Gherkin feature files (e.g., TicketBooking.feature)
βββ Hooks/ // Playwright setup and teardown hooks
βββ Pages/ // Page object models (Home, Event Details, Booking pages)
βββ StepDefinitions/ // Reqnroll/SpecFlow step definitions binding Gherkin to Playwright
βββ TicketBooking.feature // Acceptance tests in Gherkin syntax
```
---
## Contributing π€
Contributions are welcome! If you have suggestions, bug fixes, or new features, please open an issue or submit a pull request.
**Maintainer:** [phmatray](https://github.com/phmatray)
---
## License π
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
---
Happy coding and testing! π