RSS Feed Subscribe to RSS Feed

 

Blog post summary: Quality Assurance is Not About Testing

The following is a summary of Quality Assurance is Not About Testing by Matt Lievertz. I have also incorporated some elements of his earlier The Death of the Non-Coding QA Role post too.

(more…)

Tags: , ,

Shift Left

Defining the term shift left to mean testing earlier in the development cycle feels antiquated since waiting until development is “complete” before testing is a plain ol’ anti-pattern at this point.

A better definition could be testing earlier and more frequently. Writing tests each sprint, and running those tests with every commit.

Perhaps better still is thinking of shift left as a movement of testing to earlier in the pipeline. Favor unit tests, which typically run in the pipeline first and fast. Heavier-weight tests, such as UI based and end-to-end tests, which are typically harder to write, slower to run, and run later in the pipeline, do have a place but should be used sparingly.

Another way to look at this is that shift left means shifting down the testing pyramid.

 

(more…)

Tags: , , , ,

Modern Software Testing

As a follow on from my last post about Martin Fowlers article on Testing Shapes e.g. Pyramid and Trophy), Tim Bray‘s post on modern software testing (or, “Testing in the Twenties” as he titled it) caught my eye. Bray believes that these Testing Shapes are “misshapen blobs” that are all “seriously wrong in important ways”. I do like people with opinions 🙂

(more…)

Tags: , , ,

Blog post summary: Test Shapes by Martin Fowler

In his post, “On the Diverse And Fantastical Shapes of Testing“, Martin Fowler talks about the Test Pyramid and Test Trophy, but concludes that the proportions suggested by each are much less important that writing fast, reliable, expressive tests with clear boundaries.

(more…)

Tags: , , , , , , ,

Book summary: Distributed Systems Observability

“Distributed Systems Observability” is a book from Cindy Sridharan (find her on twitter, and medium), available as a free download here (registration required). At a little over 30 pages and 8,000 words, it is not a difficult read, and I definitely recommend it.

 

 

 

(more…)

Tags: , , , , , , , ,

Testing in Production

Note that I gave a talk on this blog post in Dec ’18, if you prefer to watch that: https://www.youtube.com/watch?v=-b4QaEuFkP0

 

“Testing in production” used to be a joke. The implication was that by claiming to test in production, you didn’t really test anywhere, and instead just winged it: deploying to production and hoping that it all worked. Times have changed however, and testing in production is becoming accepted as a best practice.

(more…)

Tags: , , , , ,

Running an individual unit test with maven

Individual tests can be run from maven. This must be done from within the folder that contains the source (as in the folder that contains src/test/java), which will likely be either be the root of your maven project, or in one of your modules.

For surefire (unit tests), to run a whole test class, this will be something like:

mvn -Dtest=com.your.package.YourTest test

or, to run a specific test method:

mvn -Dtest=com.your.package.YourTest#testMethod test

For failsafe (integration tests), it will be something like:

mvn -Dit.test=com.your.package.YourIT verify

This is covered in the maven surefire plugin docs and maven failesafe plugin docs respectively, but those examples don’t mention packages names, which are required.

Tags: , , , , , , ,

Running tests in IntelliJ for a multi module maven project

This post shows how to run all the tests in IntelliJ for a multi module maven project.

(more…)

Tags: , , ,

Unit Testing – the Hard Parts @ NYC Code Camp

Thanks to everyone who came to my “Unit Testing – the Hard Parts” presentation @ New York Code Camp. I really enjoyed it! Great crowd, lots of follow up questions. And cool Microsoft office space in Times Square. Thank you to all who attended. My slides are here: http://www.slideshare.net/shaunabram/unit-testing-the-hard-parts

Tags: , , , , , , , , ,

Test Doubles: mocks, dummies and stubs

Most classes have collaborators. When unit testing, you usually want to avoid using real implementations of those collaborators to avoid test brittleness and binding/coupling, and instead use Test Doubles: Mocks, Stubs and Doubles.

This article references two existing articles on the subject: Mocks Aren’t Stubs, by Martin Fowler and The Little Mocker, by “Uncle” Bob Martin. I recommend them both.

 

(more…)

Tags: , , , , , , , , , , ,

Testing private methods in .Net

Feeling the need to test private methods is usually a sign that your code needs refactoring. The recommended approach is that you test your code via it’s public interface. Since your private methods are only accessible via those public methods, it goes that if you have thoroughly testing via the public interface, your private methods will have been tested too.

Still, there can be times testing private methods can be useful. For example, while dealing with either legacy code or when using it as a temporary step while refactoring.

How do you do this in .Net?

(more…)

Tags: ,

AssertJ > Fest > Hamcrest

I have previously blogged about Hamcrest, and using its assertThat methods in preference to JUnit’s Assert.

However, I quickly after discovered FEST Assertions, and happily switched to it. It provides the same improved test readability and failure messages as Hamcrest, but has the extra benefit of enabling IDE auto completion, rather than having to search through package and class docs to find the right matcher.

Unfortunately, Fest seems to not longer be actively developed. The last stable release of the 1.x branch, 1.4, was released way back in 2011, and the new 2.x branch never made it to a stable release and hasn’t had a commit since June 2013.

Enter AssertJ

(more…)

Tags: , , , ,

Testing for expected exceptions in JUnit

Unit tests are used to verify that a piece of code operates as the developer expects it to. Sometimes, that means checking that the code throws expected exceptions too. JUnit is the standard for unit testing in Java and provides several mechanisms for verifying exceptions were thrown. This article explores the options and their relative merits.

(Note: There are other good options for testing for exceptions using AssertJ, rather than vanilla JUnit. See https://www.baeldung.com/assertj-exception-assertion)
(more…)

Tags: , , ,

Builder Pattern: Good for code, great for tests

I’ve found the builder design pattern occasionally useful in code, but frequently useful in tests. This article is a quick summary of the pattern in general, followed by look at a working example of using it in tests. See the code in github.
(more…)

Tags: , , ,

Software Quality via Unit Testing

The following post is based on a talk I gave at Desert Code Camp 2013. See also the associated slide deck.

Software quality is critical to consistently and continually delivering new features to our users. This articles covers the importance of software quality and how to deliver it via unit testing, Test Driven Development and clean code in general.
Read more

Tags: , , , , , , , , , ,