XenonStack

A Stack Innovator

Post Top Ad

Monday 19 March 2018

Test Driven & Behaviour Driven Development in Scala

Blog Single Post Image

Overview

With the evolutionary growth of software development process, Test Driven Development is an approach that consolidates test first driven methodology and refactoring.
Test Driven Development is a key practice for extreme programming, it suggests that the code is developed or changed exclusively on the basis of the Unit Testing.

TDD (Test Driven Development)

It is a practice of writing a (failing) test prior to writing the code of a feature. Feature code is refined until it passes the unit test.
Steps for the same are given below -
  • Firstly, add a test.
  • Run all the tests and see if any new test fails.
  • Update the code to make it pass the new tests.
  • Run the test again and if they fail then refactor again and repeat.
Test Driven Development Approach

BDD (Behaviour Driven Development)

Behaviour Driven Development (BDD) is similar to the Test Driven Development. In other words, Behaviour Driven Development is the extended version of Test Driven Development.
The process is similar to Test Driven Development. In this also, the code is first written in Behaviour Driven Development and the production code. But, the main difference is that in Behaviour Driven Development the test is written in plain descriptive English type grammar as opposed to Test Driven Development.
This type of development -
  • Explained the behaviour of the software/program.
  • User friendly
The major benefit of Behaviour Driven Development is that it can easily be understood by a non-technical person also.

What is Unit Testing?

Unit tests operate on a low level and are tightly coupled with source code. In the best of worlds, one unit test always correlates to one minimal piece of functionality. These functionalities are independent of the other components of the code

What is Integration Testing?

Integration tests validate that software components work correctly when combined together. Only the interfaces between components are tested and it is assumed that each component has been individually unit tested.

Test Driven Development Workflow

Test Driven Development promotes the idea of each test case testing one piece of functionality at a time. The workflow of Test Driven Development is as follows - 
  • Write a concise, minimal test for a new piece of functionality. This test will fail since the functionality isn’t implemented yet (if it passes one knows that the functionality either already exists or that the test isn’t designed correctly).
  • Implement the new functionality and run all tests, both the new and pre-existing ones. Repeat until all tests pass.
  • Clean up the code and ensure that all tests still pass, then return to step 1.
Core Overview to Test Driven Development

Test First Development in Agile

  • For this programming approach we write the tests before programming and during testing for functionality, all these test cases are run whenever we test the functionality.
  • For test first programming we can also say that we are going to write the automated test cases before the functionality and the developer has to write the test case to satisfy these tests cases.

Test Driven Development

It is the practice of first writing a (failing) test prior to writing the code for a feature. Feature code is refined until it passes tests(s).
  • Firstly when we go to design or implement a new feature we check whether an existing design is the best design which will help us to implement a new functionality.
  • If the above condition satisfies then we follow the TFD approach for the implementation of new functionality.
If the above condition is not satisfied, then it allows us to change the portion of design affected by new functionality and allows us to add new features very easily.


Continue Reading:XenonStack/Blog

No comments:

Post a Comment