Step 3

In part one of this tutorial I introduced Vue and we learned how to setup and create a simple app in vue. If you haven’t read that, here is the link. For my webapp, I had to collect names, roles…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




One Failing Unit Test

unit

Currently I am working in a project as QA where we are doing re-modelling of SQL database to a new shiny Graph DB and writing a new rest service on top of it.

In test pyramid most of the automated tests should be covered at unit level, then some at integration and few for end to end journeys.

Unit testing for most of my career was black box. Also as a gate keeper of App(this statement is debatable, lets park this for future), trusting test cases which are majority in number, which you pretend to understand and also have not written, is not very comfortable position to be in.

Hence I wanted to keep my eyes & ears open for anything which is not caught by unit test. And my wish was answered very soon.

It all started with a small ad-hock change request from a BA in our team.

BA: Hey can we please change the “id” to “key” in the response.

Dev: Sure.

QA: It will be tested in a jiffy.

Requirement

Lets look at some pseudo code

Lets assume that we are building simple App which returns Employee details. Pseudo code will look something like below.

Minimal test case & seed test data for above code will be.

Everything is good so far, developer actually failed test cases by changing “id” to “key” in assertion of testEmployeModel test case, fixed code and “Yay” TDD.

Note: fix for this is simply changing Id to key in case class, rest in taken care by spray serialization/deserialization.

While doing e2e testing we loaded data into test DB.

Hit the service and “internal server error”.

Though the fix for this bug was pretty straightforward, but it kept me thinking what could have gone wrong here. We have written unit test case for this requirement, even development was done TDD way, now how come this bug?

If you know the answer then continue else go through the implementation one more time and see if you can figure out the problem.

Change query in getEmployee method to

There are 2 fold miss in this.

Requirement from BA was never understood/explained clearly as implementation was easy and never discussed the “why” behind it. Consumer of the service wants “key” instead of “id” but also it was the database value which was going to change in the data-ingestion part.

If some more effort was spent in understanding the test case, and test data in particular for a unit test case before making any change to code, this problem must have been caught and fixed then and there itself.

But now imagine once the project matures, these test fixtures would be present in thousands of test. How would someone know what to fix/update?

Have you ever experienced this problem of updating or forgetting to update hundreds of test fixture for any change in functionality, if yes any solution/strategy to handle? Do share in comment section.

Add a comment

Related posts:

Explore The Web Searching API And Power Up Your Website

Do you need to enrich your website or app with web searches? Keep reading to find out about the API that will power up your website. Web search engines are a crucial component of the Internet…

9 Signs You Need Help With Fresh Bros

Table of ContentsOur Packwoods Blunt — Gelato Freeze DiariesSee This Report on Packwoods Blunt — Gelato FreezeOur Packwoods Blunt — Gelato Freeze DiariesFacts About Packwoods Gelato Freeze 2g Rolled…

Creating a 3D Navbar

Oftentimes when making a basic site structure, your website can begin to look stale. There are some very basic changes you can make to make your site more interesting. For this tutorial, we’ll look…