Test Driven Development
Test Driven Development
ISSN 2229-5518
Abstract— The increasing complexity of automotive software makes it highly difficult to develop the software with high quality in a small
span of time. The late detection of early errors, such as requirement inconsistencies and ambiguities, often increases software
development life cycle costs. In this approach, we discuss the Test-Driven Development (TDD) process for Automotive Software, which
introduces agile practices into the early phases of development, significantly reducing the risk of requirement inconsistencies and
ambiguities, and thus reducing development costs.TDD is one of the practical approach for improving the quality and reliability of software.
In this proposed methodology the tests are automated, the bugs are recognized and fixed, which in turn reduces the software development
life cycle costs and improves software reliability.
Index Terms— Test Driven Development, Automotive Software, Unit Testing, Automation.
—————————— ◆ ——————————
1 INTRODUCTION
A good software is very important for the proper function-
ing of the system. The increasing complexity and variations in
2 METHODOLOGIES
the automotive software has increased the burden on the de-
velopers to give quality software within a short interval of 2.1 Test Driven Development
time.[1] This has in turn led the developer to adapt Test Driv- TDD is an agile methodology that goes through these recur-
en Development methodology in the software development ring steps:-
process.
IJSER © 2017
http://www.ijser.org
International Journal of Scientific & Engineering Research, Volume 11, Issue 7, July-2020
ISSN 2229-5518
The figure 2 shows that TDD approach does not have any
significant impact on the code complexity based on survey [3]
3 THE WORKFLOW to maintain, easy to add new features and easy to maintain it
in the long run. By running all the test cases again, the devel-
3.1 TDD Workflow oper can gain confidence that is not altering any functionality
which is already existing. [4]
The fundamental steps of TDD are:-
1. A test will be written for a functionality based on the
requirement.
2. The tests will be run and see if the new test code fails.
3. Codes will be developed to pass the tests. Fig 3:-The TDD Flowchart [7]
4. The tests will be run and passed after verification.
5. Code refactoring. 3.2 Automation
6. Regression testing needs to see if no functionality has
been affected. The increasing complexity of automotive software’s
brings the need to use automation methods for performing
In the beginning a small code will be written to test the in- tasks which are repetitive in nature. The main challenge in
tended functionality. In the second step the test will be vali- automating the unit test cases is it requires the knowledge
dated to test the correctness of the code, it must be noted that of the programmer and tester. Sometimes the data for the
the test must not pass at this point of time because our code is test cases can be inferred from the system requirements or
still not functional yet. The third procedure is that of develop- the code the proper validation and preparation of unit test
ing the code. Next, the desired implemented functionality is cases demands a lot of various multiple activities.
tested by running all the test cases. Next regression testing
needs to be done to check if all the functionality is working as Automating unit test cases mainly involve the following
intended. [3] steps:-
Passing the tests shows the correct behavior telling that the 1. Creation of requirement template which identifies output
code is working. But the developer has to keep the code clean and input parameters. Fields are mapped to the parameters
and well-structured for future modifications if any. Refactor- with the unit test cases.
ing is changing the structure of the program without altering 2. Fulfillment of the requirement template by setting certain
its behavior. The sole purpose is to create a code which is easy rules which gives us the information about the initial val-
IJSER © 2017
http://www.ijser.org
International Journal of Scientific & Engineering Research, Volume 11, Issue 7, July-2020
ISSN 2229-5518
4 TDD INSTANCE
6 COMPARISON OF TDD AND TRADITIONAL TESTING
Consider an example wherin we are creating an string
element to be added in a list and checking if we are getting In TDD the test cases are written first and then refactoring
the same string from the respective class. of the code is carried out, in essence it is a code to solve a test
which is going to fail. Hence referred as Test First.
1 public void testElementList()
2 { But in traditional testing the code is written first and then
3 ElementList input = new ElementList (); the test code is written and executed. Hence referred as Test
4 input.addElements ("TDD"); Last.
5 assertEquals ("TDD", input.addElements ("TDD"));
6 } It must also be noted that refactoring is used slightly in
terms of Traditional Testing but it is not omitted .Refactoring
Consider the above test case which will throw an error as occours less frequently when programmers are addressing the
the ElementList class is still not created.The code developer code defects. [3]
will solve this error by determining the cause of the error i.e.
creating a class. 7 ADVANTAGES AND DISADVANTAGES OF TDD
Upon creating a class named ElementList the error will be
solved upon compiling, this is the first step to refactor our TDD has a major contribution to the software development
code. Methodology such as:-
1. Reduced the efforts of the developers
1 public class ElementList 2. Unit tests communicate how the software should be-
2 { have without any ambiguities.
3 } 3. Developers gain confidence of making changes to the
code any time during the development cycle and it
However, line 4 will still give an error since addElements keeps the software simple.
Method is still not created.We will solve this error by creat- 4. The software bug rates are drastically reduced.
ing a method named addElements as shown below.
While the major draw backs are:-
1 public class ElementList 1. It reduces the testers work and builds more pressure on
2 { the developer.
3 private List<String> ElementList = new ArrayList 2. The initial test writing is a tiresome process.
<String> ( );
4 public String addElements (String args) 8 CONCLUSION
5 {
6 this.ElementList.add (args);
In this paper we have discussed about the Test Driven
7 return this.ElementList.toString ();
Methodology and its various advantages in implementing it in
IJSER © 2017
http://www.ijser.org
International Journal of Scientific & Engineering Research, Volume 11, Issue 7, July-2020
ISSN 2229-5518
REFERENCES
[1] Carsten Wiecher, Joel Greenyer, Jan Korte,”Test-Driven Scenario Specification
of Automotive Software Components”, 2019 ACM/IEEE 22nd International
Conference on Model Driven Engineering Languages and Systems.
[2] John W. Burris,” Test-Driven Development for Parallel Applica-
tions”, 2017 Second International Conference on Information Systems
Engineering
[3] Shaweta Kumar, Sanjeev Bansal,”Comparative Study of Test Driven
Development with Traditional Techniques”, International Journal of
Soft Computing and Engineering (IJSCE) ISSN: 2231-2307, Volume-3
Issue-1, March 2013.
[4] James W. Grenning ,"Test Driven Development for Embedded C"
(2011, Pragmatic Bookshelf)
[5] Nalepa G.J., Kutt K., Kaczor K. (2014),"Can the Generation of Test
Cases for Unit Testing be Automated with Rules ,Artificial Intelli-
gence and Soft Computing. ICAISC 2014. Lecture Notes in Computer
Science, vol 8468. Springer, ChamD.S. Coming and O.G. Staadt, "Ve-
locity-Aligned Discrete Oriented Polytopes for Dynamic Collision
Detection," IEEE Trans. Visualization and Computer Graphics,
vol. 14, no. 1, pp. 1-12, Jan/Feb 2008,
doi:10.1109/TVCG.2007.70405. (IEEE Transactions )
[6] Ayse Tosun, Muzamil Ahmed, Burak Turhan, Natalia Juristo"On the
Effectiveness of Unit Tests in Test-driven Development", ICSSP '18:
Proceedings of the 2018 International Conference on Software and
System Process May 2018.
[7] Myint Myint Moe,"Unit Test using Test-Driven Development
Approach to Support Reusability", International Journal of Trend in
Scientific Research and Development (IJTSRD), Volume: 3, Issue: 3,
Mar-Apr 2019.
IJSER © 2017
http://www.ijser.org