A comprehensive comparison of popular API testing frameworks (Playwright, SuperTest, REST Assured) with performance testing using K6. Includes real-world examples, CI/CD integration, and detailed reporting.
- π Multiple framework implementations of the same API tests
- π Performance testing and comparison metrics
- π GitHub Actions CI/CD integration
- π Automated test reporting
- π― Real-world testing scenarios
- Playwright - For API functional testing
- SuperTest - For Node.js based API testing
- REST Assured - For Java-based API testing
- K6 - For performance testing
playwright-toolshop-api-tests/
βββ tests/
β βββ api/
β βββ petstore.spec.ts # Playwright API tests for pet endpoints
β βββ store.spec.ts # Playwright API tests for store endpoints
βββ k6/
β βββ store-performance.js # K6 performance tests
β βββ store-playwright-converted.js # K6 tests converted from Playwright
βββ java-api-tests/
β βββ src/
β β βββ main/java/
β β β βββ com/example/
β β β βββ model/ # Java model classes
β β βββ test/java/
β β βββ com/example/
β β βββ config/ # Test configuration
β β βββ tests/ # REST Assured tests
β βββ pom.xml # Maven configuration
β βββ testng.xml # TestNG configuration
βββ swagger/
βββ can-system-v1.json # Swagger API specification
- Node.js (v14 or higher)
- Java JDK 11 or higher
- Maven
- K6
- Clone the repository:
git clone [repository-url]
cd playwright-toolshop-api-tests
- Install Node.js dependencies:
npm install
- Install Java dependencies:
cd java-api-tests
mvn clean install
# Run all Playwright tests
npm run test:playwright
# Run specific test file
npx playwright test tests/api/store.spec.ts
npm run test:supertest
cd java-api-tests
mvn clean test
# Run basic performance test
k6 run k6/store-performance.js
# Run converted Playwright tests with K6
k6 run k6/store-playwright-converted.js
- HTML reports are generated in
playwright-report/
directory - View the report using:
npx playwright show-report
- TestNG reports are generated in
java-api-tests/target/surefire-reports/
- Performance metrics are displayed in the console
- Can be integrated with Grafana for visualization
The test suite covers the following endpoints:
- Create order
- Get order by ID
- Get store inventory
- Delete order
- Create pet
- Get pet by ID
- Update pet
- Delete pet
The K6 performance tests include:
- Smoke testing (1 user, 30 seconds)
- Load testing (up to 20 concurrent users)
- Performance thresholds:
- 95% of requests should complete within 500ms
- Error rate should be below 10%
- Fast execution
- Simple setup
- Good for both API and UI testing
- Built-in async/await support
- Node.js native
- Clean, fluent API
- Specifically designed for API testing
- Good integration with Jest
- Java-based
- Strong typing
- Powerful assertion library
- Excellent for enterprise projects
- Dedicated performance testing
- Detailed metrics
- Configurable load patterns
- Good for CI/CD integration
This project uses GitHub Actions for continuous integration. The workflow:
-
Triggers on:
- Push to main branch
- Pull requests to main branch
- Manual workflow dispatch
-
Runs all test suites:
- Playwright API tests
- SuperTest tests
- REST Assured tests
- K6 performance tests
-
Generates and uploads test reports:
- Individual reports for each framework
- Combined HTML report
- Publishes reports to GitHub Pages
After each workflow run:
- Go to the Actions tab in GitHub
- Click on the workflow run
- Scroll down to the Artifacts section
- Download and view the reports:
playwright-report
: Playwright test resultsrest-assured-report
: REST Assured test resultsk6-report
: K6 performance test resultscombined-report
: Single HTML file with all results
You can also view the latest test report on GitHub Pages at:
https://[your-username].github.io/[repository-name]/
The workflow can be configured by modifying:
.github/workflows/test-execution.yml
: Main workflow configurationpackage.json
: Test execution commands- Individual test framework configurations
K6 performance tests report:
- Response times (p95, p99)
- Requests per second
- Error rates
- Custom metrics
These metrics are available in:
- GitHub Actions console output
- K6 JSON report
- Generated HTML report
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.