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
Software Quality Assurance ( Auburn University, Spring 2023, Fall 2023 )
Mobile Security (Tuskegee University, Spring 2023)
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
Go to the GitHub link below, and you will find the whole project and all the codes_
Apply test-driven development (TDD) to implement a subtraction operation for our simple calculator. We will use `unittest` (https://docs.python.org/3/library/unittest.html) to complete the code in a test-driven manner. Follow the step-by-step process here.
The recording of this in-class experience is available here and here.
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).
Your code should satisfy the following requirements:
The calculator must be able to multiply and divide
All methods related to mathematical operations should sanitize the input
All methods related to mathematical operations should handle division by zero exceptions
All methods related to mathematical operations should be fast
You have applied static analysis to your Python program files. Use the `Bandit` tool (https://bandit.readthedocs.io/en/latest/) to perform static analysis and report the weaknesses that you find in a TEXT file.
Complete survey: https://auburn.qualtrics.com/jfe/form/SV_556t0yGLahw3vVA