February 28, 2016

RESTful Testing with Stripe: From JSON to Object using GSON

This post is fifth in a series of six. Need to go back to the beginning?

With RESTful Testing with Stripe: Using UriBuilder, HttpGet and other Apache HttpComponents, we focused on laying groundwork for communicating with the Stripe API endpoint, sending messages and retrieving data.
  • JSON response was retrieved
  • JSON was converted it into a JSON string
  • Google's GSON library was used to place it in a data object we created.
... But how exactly did this process happen?

Let's simplify things and set all the charge object data to null in our JSON file.

February 27, 2016

Do You Actually Know What Your Automated Test Is Doing?

When it comes to automated tests for your software application, what is more important?

  • Knowing that a test passed or failed
  • Knowing how a test passed or failed 

Without adequate reporting, you will never be able to tell what is being tested, how it is being tested, and whether the test is being thorough enough.

When I was a manual tester, I always made sure to write up a test case.

  • Summary Heading : What I am hoping the test is going to accomplish
  • Steps to Reproduce: A bullet pointed list of the specific parameters I am using to test the application, and where I am entering them.
  • Results:  What did I expect the results to be? What were the actual results? Did it (PASS) or (FAIL)? 

The Steps to Reproduce were quite important. When investigating the possible failure, they might pass with a similar set of parameters, but only fail with the exact parameters you used.

February 25, 2016

RESTful Testing with Stripe: Using UriBuilder, HttpGet and other Apache HttpComponents

This post is fourth in a series of six. Need to go back to the beginning?

Now that we built a skeleton framework to test using the Stripe REST API, storing and retrieving the API Key, we can perform actions. We are going to:
  • Create a method called getListOfCharges in our StripeUtils class, where we can pass in how many charges we wish to retrieve. 
  • Create a data object to hold all the information we retrieve.
  • Add functionality that turns the JSON object we get back, and add all information into the data object we created, using Google's GSON library.

What Our Framework Will Look Like

By the end of this blog post, our automation framework will look like:

February 23, 2016

RESTful Testing with Stripe: Storing API Keys in properties files and initial setup of StripeUtils

This post is third in a series of six. Need to go back to the beginning?

So far we covered why we should incorporate tests other than UI tests into our automation test suite. We gave a brief background on RESTful APIs. And we showed how to interact with the Stripe API through GET methods with HTTPS and POST methods with cURL.

Now, we can start writing code to interact with Stripe! We are going to:
  • Store the Stripe API Key in a properties file, pretending that the general purpose key is actually two different keys: One for the US and one for Canada.
  • Write a method to Load the Properties
  • Create a basic Stripe Utilities that forces the user to select which country we are using. Using that information the proper API key is loaded. 
  • Start writing a test class containing tests that confirm Stripe Utilities can only be instantiated if and only if the country is either US or Canada. 

What Our Framework Will Look Like


February 20, 2016

Subscribe to Adventures in Automation!

Want the latest updates for Adventures in Automation? Subscribe to this blog!

Adventures in Automation has been set up with Google's Feedburner, a web feed management provider. Whether you use MyYahoo, Feedly, Netvibes, SubToMe, you can subscribe to the blog's RSS feed. If you wish, you can subscribe via Email, and get blog posts delivered directly to your inbox.


  Subscribe to Blog:

February 18, 2016

RESTful Testing with Stripe: Interacting with Stripe using HTTPS and cURL

This post is second in a series of six. Need to go back to the beginning?

With our last couple of blog post, we talked about how automation needs to be more than simply browser tests, and we covered the early history of RESTful APIs. Before diving into writing a framework from which we can build automated API tests, I wanted to go over their basic interactions.

Interacting with a RESTful API such as Stripe's is as simple as interacting with a web page:
  • GET Methods, such as what automatically happens when you go to a website like http://www.tjmaher.com/ ... Your browser accesses the HTML code returned, and interprets it as a web page. You are getting information from the endpoint. 
  • POST Methods, such as when you fill out a form on the web or send data such as a Comment. You are sending data to the endpoint. 
We will be interacting in a rudimentary way with RESTful API's such as Stripe:

  • To GET, we will be using simple HTTPS calls
  • To POST, we will be using a program called cURL.


February 16, 2016

RESTful Testing with Stripe: Brief introduction to REST APIs

Before launching into a discussion how to test REST APIs such as Stripe's API used to process payments, I wanted to take a step back and talk about what they are and their early history.

With the RESTful API webservice, software developers allow web apps to interact with their software products as easily as you and I interact with a web page.
  • GET Methods: To access Adventures in Automation, your browser made an HTTP Request to the web server at http://www.tjmaher.com/, which in turn served you the HTML code that your browser interpreted as a web page. 
  • POST Methods: When you enter a message into the Comments textbox at the bottom of this page, then hit the "SHARE" button, the information entered is posted to the web server for processing. 
RESTful APIs are quite common. Fitbit has one. Amazon has a whole suite of them.  Even Boston's subway system, the MBTA has, one. But where did this idea come from? And what is an API?
"API (application program interface) is a set of routines, protocols, and tools for building software applications. The API specifies how software components should interact and APIs are used when programming graphical user interface (GUI) components. A good API makes it easier to develop a program by providing all the building blocks. A programmer then puts the blocks together".
- Webopedia

February 14, 2016

Coming up: RESTful Testing: How to work with RESTful API's using Apache's HTTPComponents and Java

The next series of blog posts will cover my latest project as an automation developer at Fitbit-Boston: Working with RESTful APIs, such as the one Stripe uses to process credit card transactions. Stripe graciously provides the general public a general use key to access their services. Topics covered:
  • Walking manual QA Engineers -- who may have a bit of Java programming experience -- through setting up their development environment.
  • Introduction and a brief history of RESTful APIs.
  • Introduction to the Stripe API and walkthrough of their excellent documentation.
  • How to interact with Stripe through Apache's HTTP Components such as HTTP Client, HTTP Post, HTTPGet, and URI Builder and Java.
I covered in my blog about how at work we were having conversations about Testing Beyond the UI: The Testing Pyramid. The work that I am doing is the next step in that process.

Please note: I've only been an automation developer for a bit less than a year, and I have only been working with HTTP Components for a few weeks, which makes me this all brand-new to me, too. That is why I am attempting this project: By forcing myself to explain what I have been doing, it will deepen my knowledge.

I was wondering, if you are more experienced that I, if you could do a code review when I am finished? I will be publishing working code on my GitHub account. Feel free to add any comments or constructive criticism in the Comments section at the bottom of the page.

These blog posts will be starting this Tuesday, and will be published every Tuesday and Thursday until the project is complete. Subscribe to this Blog to get the latest posts via email.

Thank you for stopping by!

Happy Testing!

NEXT: Intro to REST APIs


-T.J. Maher
 Sr. QA Engineer, Fitbit
 Boston, MA

// Automated tester for [ 11 ] months and counting!

Please note: 'Adventures in Automation' is a personal blog about automated testing. It is not an official blog of Fitbit.com

February 8, 2016

Testing Beyond the UI: The Testing Pyramid

Problems with UI Tests


We've been using Selenium WebDriver with Java to write automated browser tests for our eCommerce application ever since the new Fitbit-Boston was formed two years ago.

We have tests for our web application emulating how online customers purchase goods, how customer service agents place orders, such as "Create a standard order containing a year long FitStar subscription and a Fitbit Blaze, with a billing address in the US and a shipping address in Canada, with overnight shipping, paying with a Discover Card".

February 5, 2016

February 4, 2016

Thoughts on the Second Annual 'State of Testing' Survey Results released by Sauce Labs

What is the relationship at your company between DEV and QA like:
  • Artist and Art Critic?
  • Or Writer and Copyeditor?

According to Sauce Labs' Second Annual 'State of Testing Survey' released a few days ago, testers are more than likely to find the latter instead of the former.

Why? In a word: Agile.