Not Sure What Testing Pyramid Is? Learn from a SEIT, Here.

Dina Ramandha Putri
Ruangguru
Published in
4 min readFeb 26, 2020

Some time ago, I was given the opportunity to talk about the concept of Testing Pyramid with other Ruangguru engineers.

Testing Pyramid is a framework that can help and guide the development team in producing higher quality products, and I think all software developers should be familiar with this concept.

In this piece, I will share the differences between each testing method, their respective goals, and advantages. Read on!

Unit Test

A unit test focuses on testing a very small component or piece of functionality of the codebase. The goal is to validate that the unit behaves as expected in isolated conditions.

What are the advantages?

  • Gives the developer immediate feedback on whether or not their new code broke anything in the codebase.
  • Cuts down on time spent debugging problems.
  • If there is a new developer who joined the project, that person can learn easily without looking at the original code.

So, if you have, for example, a python code like this in a failed result:

Run the code above with command on your terminal.

Here you can see how a mistake in your code gives an error on the console, with information on where the error and expected result was. The resulting script will give an error because of the sum() of (1, 2, 5) is 8, not 6.

If you fix your code, your expected result should be:

The result:

Unit Test using the Test-driven Development (TDD) method

Test-driven Development is a software development methodology in which unit tests are used to drive the development process. TDD uses a “test first” approach. This means a test code is written before the actual code.

TDD steps:

  • Write a single unit test describing an aspect of the program.
  • Run the test, which will most likely fail because the program lacks that feature.
  • Write just enough code to make the test pass.
  • Refactor the code to the simplest level.
  • Repeat accumulating unit tests over time.

Component Test

A component test is when testing is performed on each individual component separately. Other components do not integrate. The goal is just like unit test: validating that the unit behaves as expected in isolated conditions.

What are the advantages?

  • Finds defects in the modules and verifies software function.
  • It helps with faster delivery.
  • Creates more reliable systems because used components were previously tested.

Find the example below:

Snapshot is verifying a component’s rendered output. Snapshot tests should be returning to HTML.

Integration Test

Integration test checks the interactions between multiple services or components. Integration testing focuses on checking data communication amongst these modules.

There are several goals to integration test: 1) testing the interfaces between the units or modules 2) check the combinational behavior 3) validate whether the requirements are implemented correctly or not.

What are the advantages?

  • Makes sure that integrated modules/components work properly.
  • Detects the errors related to the interfaces.

End-to-End Test

This is the test of all tests, the one that checks whether our entire application is functioning as expected, that the application is working from start to finish. In other words, an end-to-end test verifies front end and back end integration. The goal here is to emulate a real user’s scenario.

What are the advantages?

  • Ensure the correctness of the application.
  • Detects bugs.
  • Expand test coverage.

End-to-End Testing can also be divided into three categories, which are:

  • User Functions
  • Conditions Based On User Functions
  • Based on Test Cases

For more information, you can check some of these references:

www.testim.io

www.guru99.com

https://www.leadingagile.com

Thanks so much for reading my piece! My name is Dina, and I am a software engineer in test (SEIT) in Ruangguru, where I’ve learned and tested on many mind-blowing new products and features. If you’re looking for opportunities where you can be part of groundbreaking innovation for education, click here!

--

--

Dina Ramandha Putri
Ruangguru

My tests haven’t failed, they’re just pre-successful~