Technology Highlight: Focus on What We Do Best Product Roadmap: Automated Testing Part 3 of 3

Posted on by

office-594132_640As we outlined in our last two technology highlights, automated testing is an essential part of our product development lifecycle. We reviewed in detail the power and simplicity of using Watir WebDriver to interact with and verify what is displayed in the user’s browser. However, our automated testing processes are just that, a procedural technique to interact with the browser; and often our tests require another layer of complexity to fully test all of the aspects of the eOriginal® software.

Another Layer of Testing: RubyGems

We couple Watir with additional Ruby tools called, RubyGems. Before explaining how we utilize RubyGems here at eOriginal, let’s first introduce you to RubyGems. By definition,  RubyGems act as a central toolbox for the Ruby programming language to provide a standard format for distributing Ruby plugins, extensions, and tools. These additional tools extend the base functionality of the Ruby language and are called gems. Developers can install different gems on their local machine and utilize them for testing projects.

One of the gems that allow us to fully test all aspects of eOriginal’s software is the Ruby Mail Gem. The Mail Gem is an internet library for Ruby that is designed to send and read emails in a simple, Ruby-esque manner. Thanks to the Mail Gem we are able to test an array of functionalities within the eOriginal software, such as parsing the SMS PIN in an SMS message sent to a Google Voice account or verifying the proper email notification is sent when it is triggered.

In the last two posts we explored the example of sending a one-time use SMS PIN and verifying that it was successfully inputted. However, we did not cover how our test received the unique, one-time use SMS PIN. How did we do that you ask? Great question!

How We Create a One-Time Use SMS PIN

Through our Watir testing-suite, the test logs into the Signing Room of the eOriginal SmartSign® platform and clicks on the button to send a one-time use PIN to the pre-configured phone number; an SMS message is then sent out with this PIN. To retrieve the SMS message, we use Google Voice, which has similar functionality to a cell phone, with a few cool tricks. Google Voice allows you to read SMS messages over IMAP (just like an email).

Before using the Mail Gem we must connect to our Google Voice account over the IMAP protocol. To do this, we use the Ruby Net::IMAP class that helps us log into our Google Voice account.

            imap= Net::IMAP.new(‘imap.google.com’)

imap.authenticate(‘LOGIN’, ‘fakeaccount@gmail.com’, ‘fake_password’)

imap.select(“inbox”)

After searching for the correct message using the IMAP search method we are able to utilize the Mail Gem. We take the message that we found with our search and send that string of code to the Mail class. This will create a Mail object that will allow us to easily manipulate the message.

mail = Mail.read_from_string subject_message

Now that we have a Mail object, we want to remove all of the “instructions” that are around that message, as we just want the “normal” text to appear within the message.

body_message = mail.body.decoded

Once we have successfully found and parsed our SMS message, we are left with just our text message (i.e. “Your one-time use PIN is: Ab3C”).  Next, we need to parse out the code Ab3C and pass it back to Watir to enter the signing room. To do this, we use a regular expression to find the PIN. We know that in our SMS message the PIN is always bolded with a <strong> tag, so we tell the regular expression to find the PIN via this tag.

sms_pin_regex = /<strong>(.+)<\/strong>/.match(body_message)

sms_pin = sms_pin_regex[1]

Now that the PIN lives within a variable named sms_pin we can pass that over to Watir to continue the test.

Recap

Here, at eOriginal, we are dedicated to ensuring our products and services are functioning as they should. With an experienced Automation Team, we take testing very seriously to ensure that we properly generate repeatable and reliable automated tests. Our team allows the remainder of our IT team to focus on our eAsset® Management Services without worrying about how or if their changes will be tested and validated.

 

This entry was posted in software development, Technology and tagged , , .