M1- Automated Requirements Validation

Description

Software requirements are a detailed description of what a software system should do, including its features, functionality, constraints, and specifications. These requirements serve as a blueprint for software development, guiding the design, coding, and testing phases. Software requirements are the most important step of the software development process, as they help ensure that the final product meets its users' and stakeholders' needs and expectations. 

We will discuss and implement software requirements for our simple calculator app in Python. 

Courses Where This Module Is Integrated

Activities

 Pre-class Content Dissemination  

Requirements engineering is the process of discovering, analyzing, documenting, and validating the requirements of the system. Each software development process goes through the phase of requirements engineering. Engineered requirements are often translated to software features through different software development methodologies, such as test-driven development and behaviour development. We will use both test-driven development and behavior-driven development in this module.  

Test-Driven Development (TDD) is a software development methodology where automated tests are written before writing the actual code. It follows a cycle of writing a failing test, writing code to make the test pass, and then refactoring the code while ensuring the test remains successful.

Behavior-Driven Development (BDD) is a software development methodology that mainly works on defining the behaviour of a software system from the end-user perspective. It emphasizes collaboration between developers, testers, and non-technical stakeholders to create executable specifications in plain language. These specifications, often called "user stories" or "scenarios," guide the development process and help ensure the software meets user expectations.

In-class workshop 

Code Examples


# test.py


import unittest

import source



class TestCalc(unittest.TestCase):

   def testSub1(self):

       self.assertEqual(1, source.performSub(2, 1), "Bug in implementation. Results should be 1.")   


   def testSub2(self):

       self.assertEqual(10, source.performSub(20, 10), "Bug in implementation. Results should be 1.")   


   def testDivZero(self):

       self.assertEqual("Put in correct divisor", source.performSub(20, 0), "Bug in implementation.")   


if __name__ == '__main__':

   unittest.main()


# source.py

def performSub(x, y):

   return x - y


Post-lab experience:

For this part of the workshop, you will develop two Python program files to demonstrate that you have practiced test-driven development (TDD).