This small piece of code represents the incipient stage of a test automation framework based on the Screenplay pattern but slghtly adapted to API testing. It is capable of basic interactions with Open Weather Map API and Reddit API.
- Java 11: programming language of choice
- Gradle: dependency management and build tool
- JUnit: testing framework driver
- REST-assured: REST services testing framework
- jackson-databind: complementary library for REST-assured to allow JSON messages unmarshalling
- dotenv: simplistic configuration loading library
- logback: logging library
src
└─main
└─java
└─com
└─curve
└─weather
└─core
| └─api - abstracted API level interactions
| └─screenplay - screenplay pattern building blocks
└─domain
└─reddit - Reddit specific API adapters and screenplay interactions
└─openweather - Open Weather Map specific API adapters and screenplay interactions
.circleci/config.yml - CI configuration-as-code file
gradle.build - handles all the dependencies and information about the build process
gradle - Gradle wrapper folder, allows to run the tests without installing gradle
src\test\java\com\curve\weather\WeatherFlowsTest.java - test cases location
The only requirement is to have Maven and Git installed and configured properly. See: https://maven.apache.org/install.html for Maven and for Git https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Easy as π. Just clone the repository.
Before running tests check .env file and populate the following key values:
- REDDIT_PASSWORD (Reddit password of the user who has allowed the client app)
- REDDIT_CLIENT_SECRET (user associated client app secret)
- REDDIT_CURVE_RECIPIENT_USERNAME (account with this username will receive the PM)
Once those are set make use of the Gradle wrapper and run the test task in the root of the project where build.gradle is located:
gradle.bat test - cmd
./gradlew test - bash
TBC - Naming conventions for Action/Task/Check TBC - Opening PRs (GitFlow)
Bare-bones test framework structure created and is includes perform the following:
- Define BDD style scenarios using basic Screenplay DSL
- Make REST service API request
- Un-marshal and check response obtained
- Allows integration into CI/CD pipeline
- Improved logging, which is rather simplistic currently
- Templating engine to simplify Reddit post body creation
- Sane approach to context sharing (instead of using memory as context)
- Refactor of the Adapter layer (currently hides some actions to avoid a complex screenplay layer)
- Extension and re-factoring of the checks
- The goal is allow a multitude of validation capabilities coupled with reduction in boilerplate code.
- eager test failures, i.e. actions failing after first failed check
- Explicit messages when check fails, currently just pass/fail
- Custom reporting capabilities
- Showcase what is being tested and the value of the tests being run to non-technical people.
- Test evidence (more in-depth extensive test run logs) gathering is also being developed
- Code quality metrics
- Parallel execution capabilities
- Unit tests for core framework functionality
- More extensive modeling of responses/requests
I would advise against using this piece of code as a performance testing tool. It is better suited as a functional, ideally E2E, testing tool. For non-functional testing purposes I would advise creating a separate framework/module.