AWS Developer Blog

Tag: Testing

Client Response Stubs

We recently added client response stubs to the aws-sdk-core gem. Response stubbing disables network traffic and causes a client to return fake or stubbed data. # no API calls are made s3 = Aws::S3::Client.new(stub_responses: true) s3.list_buckets.buckets.map(&:name) #=> [] Custom Response Data By default, stubbed responses return empty lists, empty maps, and placeholder scalars. These empty […]

Read More

Using RSpec 3

Using RSpec 3 I have been a long time user of RSpec and many of the Ruby projects I work with use RSpec as the primary testing framework. It provides an expressive specification DSL. As you may know, RSpec 3 is currently in the works. I have blogged a few times recently about using MiniTest. […]

Read More

Using SimpleCov with Multiple Test Suites

It can be helpful to generate coverage reports when testing software. While coverage reports do not guarantee well tested software, they can highlight were test coverage is lacking. This is especially true for legacy, or un-tested projects. Recently I ran into a situation where I wanted to generate a coverage report, but the project used […]

Read More

Running Your Minitest Unit Test Suite

I have blogged a few times recently about Minitest. With Minitest you need to chose how you will execute your tests. When using other tools, like Rspec, there is a bundled test runner. $ rspec ………… Finished in 0.03324 seconds 12 examples, 0 failures Minitest does not provide a test runner as a command line […]

Read More

From Minitest::Spec to Minitest::Test

In a previous blog post, I introduced Minitest from the perspective of RSpec. Some Minitest users prefer to avoid the specification style of Minitest::Spec. Instead they use Minitest::Test. It’s closer to the metal and uses a more vanilla Ruby syntax. Here is an example spec file using Minitest::Spec: require ‘spec_helper’ describe MyClass do describe ‘#some_method’ […]

Read More

From RSpec to Minitest

One of my favorite aspects of working with Ruby is how natural it is to write tests for. The Ruby community does an excellent job of encouraging authors to produce well tested code. There is a plethora of well supported tools to choose from. I like to joke that new Ruby developers write Micro test […]

Read More

Static Service Client Facades

Version 2.4 of the AWS SDK for PHP adds the ability to enable and use static client facades. These "facades" provide an easy, static interface to service clients available in the service builder. For example, when working with a normal client instance, you might have code that looks like the following: // Get the configured […]

Read More

Stubbing AWS Responses

I come across questions frequently about how to test an application that uses the AWS SDK for Ruby (aws-sdk gem). Testing an application that makes use of an external service is always tricky. One technique is to stub the client-level responses returned by the SDK. AWS.stub! Calling the AWS.stub! method in your ruby process configures […]

Read More

Faster AWS Tests with VCR

Performing integration testing against a live AWS service can often be inefficient since you are forced to make requests across the network for every test. Fortunately, there are tools that you can use to help reduce the amount of network traffic your tests require and make them run faster in the process. We will look […]

Read More