Search by labels

Thursday, September 15, 2022

The Penny Game

Or why when embracing Agile, individual productivity decreases, but the team's productivity greatly increases.



Monday, June 27, 2022

Automating E-Mail Test Cases When Using Twilio SendGrid

   SendGrid is a customer communication platform for transactional and marketing email, which boasts an impressive client portfolio with big names like Uber, Spotify or Booking.com.

   Let's look into automating a simple test scenario that will check if new users that sign-up for a test application will also receive their welcome e-mails. 

   The presented small test suite only details the e-mail verification part, as the sign-up part can be done in multiple ways - UI action, API call, etc. and is application specific. 

   The test case uses the RestAssured Java library with a previously created API key to call the SendGrid API and check for the e-mail event of interest.

@Test

@Order(0)

void signUp(){

// perform user sign-up

}


@Test

@Order(1)

void verifySendGridEmailEvent() {

    sleep(asyncWaitingTime); //it is an async process so waiting time has to be allowed


    given().log().method().log().uri().header("Authorization", "Bearer " + sendgridApiKey)

            .when().get("https://api.sendgrid.com/v3/messages?limit=1&query=to_email=\"" + emailAddress + "\"")

            .then().statusCode(200)

            .body("messages[0].subject", equalTo("Welcome to Going T-Shaped!"),

                    "messages[0].from_email", equalTo("no-reply@goingtshaped.blogspot.com"),

                    "messages[0].to_email", equalTo(emailAddress), // the e-mail address from the previous sign-up test

                    "messages[0].status", equalTo("delivered")); // e-mail accepted at the receiving server


    System.out.println("Welcome E-mail event correctly retrieved from Sendgrid for user " + emailAddress);

}


   So a quick and simple way of making sure that users are not missing any important e-mail communications due to unforeseen bugs. The above test case can be easily adjusted for any types of e-mails just by switching the verified attributes, e.g. e-mail subject from "Welcome to Going T-Shaped!" to "Forgot Your Password".