Testing Related

In this page I want to share testing related code, and perspectives.

In last week, I had some meeting/training session where we tested Automated Testing related tools. I meet with a new tool, at least for me, called JBehave. With this, you write test scenarios with a specified language, called Gherkin language.

The Gherking language is in fact the "normal" English, constructed in a very logic way, describing in a very strict way a test scenario.

The base entity in JBehave is a so called story. The story will contain scenarios and the scenarios are containing steps. You can think on this like, the entity which contains the testing of a module, is the story. The module has different parts, functions, testing those are described in a scenario, and the test of the function consist on some steps, like setting up the test, doing preparation and executing the test itself.

An example for a story is something like:

General Requirements: Core functionality must be available
//Define global values
Meta: 
@referenceURL http://www.some-url-for-promo.com
@price 2.99EU

Narrative:
In order to send a promo SMS
As a user
I want to type in the message and send it


Scenario: create a promo SMS, send it and check if was sent out

Given the device deviceID
And message 'Check this cool site $referenceURL, it is just $price' is in smsArea textarea
When the user clicked sendMessage button
Then the sent sms 'Check this cool site $referenceURL, it is just $price' appears in 'sent messages' log



This is mapped to Java in the following way

package org.rugina.tdd.demo; import org.jbehave.core.annotations.Given; import org.jbehave.core.annotations.Then; import org.jbehave.core.annotations.When; public class DemoScenario { @Given("the device $deviceID") public void givenTheDevice(String deviceId) { //TODO: logic } @Given("message '$message' is in $area textarea") public void givenMessageIsInTextArea(String message, String textArea) { //TODO: logic } @When("the user clicked $buttonName button") public void whenTheUserClickedButton(String buttonName) { //TODO: logic } @Then("the sent sms '$message' appears in '$logName' log") public void thenTheSmsIsInLog(String message, String logName) { //TODO: logic } }

I will continue in few days. :)

Nincsenek megjegyzések:

Megjegyzés küldése