Skip to main content

New Feature Announcement - Swagger Contract Validation

Β· 2 min read
Kyrillos Nageh
SHAFT_Engine maintainer
SHAFT_Engine

Say goodbye to manual schema checksβ€”contract testing is now automated and built right into SHAFT!​


πŸ›‘οΈ What is Contract Validation?​

Contract testing ensures your API requests and responses follow the defined structure (contract), helping prevent:

  • Unexpected field changes
  • Data type mismatches
  • Missing or extra fields
  • Runtime errors in API consumers

With the latest release, SHAFT now integrates Swagger/OpenAPI schema validation for all API tests. It will fail your test automatically if the request or response doesn’t match the OpenAPI spec you provide. πŸ”₯


πŸ”§ How to Enable It​

πŸ“‚ Via custom.properties​

src/main/resources/properties/custom.properties
swagger.validation.enabled=true
swagger.validation.url=https://petstore.swagger.io/v2/swagger.json

πŸ§ͺ Or via Code​

SHAFT.Properties.api.set().swaggerValidationEnabled(true);
SHAFT.Properties.api.set().swaggerValidationUrl("https://petstore.swagger.io/v2/swagger.json");

You can toggle validation dynamically per test or test class.


βœ… What Gets Validated?​

  • Request structure (body, headers, parameters)
  • Response structure (status, body schema)
  • Alignment with your OpenAPI/Swagger definition

πŸ“„ Sample Test​

@Test
public void testCreateUserWithContractValidation() {
SHAFT.API api = new SHAFT.API("https://petstore.swagger.io/v2");

String invalidPayload = "[{\"id\":\"INVALID_ID\"}]";

api.post("/user/createWithList")
.setRequestBody(invalidPayload)
.setContentType("application/json")
.perform();

api.assertThatResponse().statusCode().isEqualTo(400).perform();
}

SHAFT will automatically validate the above request and response against the Swagger schema. ❌ If anything is off, your test will fail and report the contract violation.


🧐 Why It Matters​

BenefitDescription
πŸ§ͺ Test reliabilityEnsure tests align with backend changes
πŸ” Catch regressionsCI/CD-ready contract enforcement
❌ Reduce flakinessEliminate schema mismatch failures
πŸ” API governanceHold your APIs to their contract

New Feature Announcement - Virtual Threads

Β· 2 min read
Mustafa Agamy
SHAFT_Engine maintainer

We're starting off 2024 with a huge announcement!

SHAFT_Engine

🀝

Oracle

- The future of automation frameworks is here, and it's all about working smarter, not harder.​

- SHAFT_ENGINE, your trusty automation solution, just got a major upgrade with virtual threads, a clever trick that makes it more efficient and helpful than ever.​

- What is a Virtual Thread?​

  • Virtual-Threads, introduced with Java 21 are a new way to handle multiple tasks concurrently within a single program or application. They're the new java way for asynchronous operations.
  • Think of it like hiring a whole crew of tiny helpers. While one tractor's plowing, another can check the soil, and another can keep an eye on the weather.
  • These lightweight assistants don't need fancy equipment or guzzle up resources, meaning SHAFT_ENGINE can now handle a ton more tasks without breaking a sweat.

Now let's think of test automation. In automating a registration form, envision employing a crew of virtual threads as tiny helpers :​

  • Rather than idly waiting for the entire site to load, each virtual thread can be assigned specific tasks as soon as the relevant elements become available. For instance, one thread focuses on inputting the username, another simultaneously handles the email input, and yet another sets the password. This parallel execution optimizes efficiency, ensures prompt responsiveness to dynamically changing elements, and efficiently utilizes resources.
  • As the crew of virtual threads collaborates seamlessly, the registration form is filled and submitted swiftly, providing a more agile and responsive automation process compared to traditional sequential approaches.

- Save your execution Time :​

  • That's not all, SHAFT_ENGINE utilities the Virtual Threads for Engine launch and configuration which will make your overall experience a lot faster and swifter.

Bing AI framework comparison

Β· 3 min read
Mohab Mohie
SHAFT_Engine creator

We asked Bing AI to compare SHAFT against some of the well known test automation options, here's what it had to say:

Sure! Here is an expanded comparison between SHAFT_Engine, native Selenium WebDriver, Cypress and Microsoft Playwright in a tabular format:

FeatureSHAFT_EngineSelenium WebDriverCypressMicrosoft Playwright
Web GUI testingYesYesYesYes
Mobile testingYesNo (Appium required)NoNo
API testingYesNoYesNo
CLI testingYesNoNoNo
Database testingYesNoNoNo
Built-in test synchronizationYesNoYesYes
Built-in logging and reportingYesNoYesYes
Integration with third-party tools (e.g. Jira, Xray, Browserstack)YesNoLimitedLimited
Unlimited access to underlying frameworks (e.g. Selenium, Appium, RestAssured)YesN/AN/AN/A
Cross-browser testing supportYes (via Selenium)YesLimited (Chrome, Firefox, Edge)Yes (Chromium, Webkit, Firefox)
Parallel test execution supportYes (via TestNG)Yes (via TestNG or JUnit)YesYes
Language supportJava onlyMultiple languages (Java, Python, C#, Ruby, JavaScript)JavaScript onlyMultiple languages (JavaScript, Java, Python, .NET C#)
Open-sourceYesYesYesYes
Community support and resourcesLimited compared to Selenium WebDriver and CypressExtensiveExtensiveGrowing
User guideAvailableAvailableAvailableAvailable

What do you think? Is SHAFT the better option?

New release announcement (7.1.20230309)

Β· 2 min read
Mohab Mohie
SHAFT_Engine creator

Release highlights:​

Technical Details:​

  • SHAFT has always boasted top-notch reliability, but this sometimes comes at the cost of performance. In this release we made a major change to the way we handle "Type" which is one of the most commonly used and also one of the slowest actions.
  • Previously SHAFT would perform the following Selenium WebDriver calls:
    • Get Element Accessible Name (for reporting)
    • Get Current Element Text (to learn how this element stores its text and to learn the initial text if any)
    • Get Current Element textContent (to learn how this element stores its text and to learn the initial text if any)
    • Get Current Element Value (to learn how this element stores its text and to learn the initial text if any)
    • Clear (in case the element text wasn't empty)
    • Send Keys (to do the actual typing)
    • Get text using the successful text identification strategy (to validate that the text was typed correctly. if SHAFT ws able to find out which method out of the above three to use it will use it, else it will do all three calls again)
  • And inside each call, SHAFT would go into a fluent wait where it calls:
    • findElement
    • findElements
  • This means that SHAFT did 21+ webdriver calls!
  • Starting this version SHAFT will cut that number down to just 3 webdriver calls while maintaining the full functionality.
  • Using jsoup SHAFT will capture the entire HTML of the target webelement, and will then be able to uery it for the text/textContent/Value as need to clear and validate successfully typing.
  • SHAFT will also grab all element information (including the WebElement object) once, and will use the WebElement object directly (which is much faster than finding the element again each time) but if the engine faces a WebDriverException (like StaleElementException) the engine will go into a fluent wait to find and update the element reference.
  • We tested this major change thoroughly by running around 1700 E2E Test scenarios across different platforms, so we're confident it's stable.
  • In following releases we will rollout this approach to all our element actions, and next on the list we have "Click()" which is the second most used action per our analysis.

Dear SHAFT users, we need your support!

Β· One min read
Mohab Mohie
SHAFT_Engine creator

SHAFT is undergoing some major changes in its steering committee and we want to ensure that we align our strategies to what you guys really need!

SHAFT_Engine has always been (and will continue to be) a community driven project, made by Testers for Testers, and our mission was always to add value, remove redundancy, and help Software Engineers in Test focus on the exciting and non-repetitive parts of their work. For that we need your support to pinpoint and prioritize the features that you're using, and the features that you'd like to see in the near future.

Join us, become an honorary member of the new SHAFT_Engine Technical Leadership Committee by filling out this short survey, and watch your name shine as an honorary member on the dedicated page that we'll create on our official user guide!

Join us now!​