Getting Started
Writing Tests
Writing Tests
Introduction
In Skyramp, writing tests is easy. Using a simple programming style, you can define test scenarios, endpoints, and assertions effortlessly. Skyramp makes testing straightforward, helping you ensure your applications and services work reliably.
The following section describes the basic anatomy of a test so that you can manually create your own and take advantage of Skyramp's powerful automatic test generation capabilities described in the next section.
For the purpose of the upcoming guides, we will use Smartbear's "Simple Artist API" as an example. The Simple Artist API is a simple service that allows consumers to obtain a list of stored artists and add new artists to a database. Below is a snippet of the OpenAPI spec:
1. Initializing Endpoints
To commence testing API services with Skyramp, you first need to define endpoint objects. These objects encapsulate the details of the API endpoint you want to test, such as its name, port, and relevant path. Here’s an example of initializing an endpoint for the Artist REST service:
2. Defining Request Objects
Once endpoints are initialized, you can define request objects, representing requests to be made to the specified endpoints. This includes specifying request methods, payloads, and other relevant details.
3. Constructing Test Scenarios
Test scenarios define a series of steps to be executed during testing. These steps involve making requests defined in the previous step and asserting expected outcomes.
4. Configuring and Executing Tests
Test configuration logic orchestrates the execution of defined scenarios. This involves configuring various parameters such as address, test name, and execution environment. You can find more detailed instructions in the Test Configuration section.
Missing a dependency?
Skyramp makes it easy for you to quickly mock an internal or external API - saving you time so that you can focus on writing software instead of managing dependencies. You can find detailed instructions and examples here:
What's Next
Instead of writing tests by hand, you can further streamline your testing process by dynamically generating tests leveraging the Skyramp terminal client’s tester generate
command. This allows you to automate test case creation, reducing manual effort and ensuring thorough test coverage. Learn more about generating tests here.