Write My Paper Button

WhatsApp Widget

ATHE Level 4 Unit 15 Software Testing Frameworks Assignment: TDD and BDD Strategy for Medical Data Validation Script in Python

Unit 15 Software Testing Frameworks and Methodologies Assignment

Note to Learners

For this assignment, you will be creating test plans for code already provided. A unit testing framework in Python such as UnitTest or PyTest are suggested, or similar. Your tutor will help you set this up if needed.

Assignment Scenario

You have been working as a software tester for a medium-sized software development studio, headquartered in the large municipality of Centrala, that specialises in building commercial software applications for various platforms.

Your studio has recently been approached by Centrala’s University (CU) to help with the development of a tool that can be used by IT literate staff in their Medical school to safely search, download, validate and safely store medical data files in an interactive manner.

Do You Need Assignment of This Question

niversity’s trusted scientific partner whom they work with on leading medical research projects. The University’s Medical school needs to be able to download critical pharmaceutical trial data from this partner in a way that is both secure and reliable. At the moment this is achieved using a simplistic FTP service but it will be succeeded by a more sophisticated RESTful web-based API in the future.

The development team is aware that all medical data files must be strictly validated (using a set of documented rules) before they are accepted, copied for investigation, and then securely archived in a logical directory hierarchy (or be rejected if found to be “bad”)

Due to the pharmaceutical nature of the data, it is incredibly important that there are no duplicated data sets; this could create bias problems during analysis.

While the main development team assigned to the project are busy coding a solution to find, download and validate actual medical data files, a small sub-team has been hard at work creating a Python script which creates “sample” medical data files for the development team to practice on.

The sub-team has now completed this script, based on the data file specification provided, and it has been passed to your team for testing and sign-off.

It is likely the behaviour of this code can be tested using TDD and BDD principles.

Submitted Python script

The following Python script has been submitted by the development sub-team:

This code is based on rules provided by the Medical School within the University. It is hoped that this code not only works correctly, but also gives your studio’s main development team suitable medical data files, in the correct CSV format, with which to test their code. Unfortunately, it wasn’t built using TDD principles, so there may be some faults lurking in the
code or it may exhibit unexpected behaviour when it runs.

# Makes med data files for Dev team
import csv
import os
import random
import time

def make_headings(cols:int=10) -> str:
    headings = ["batch_id","timestamp"] + ["reading"+ str(num) for num in range(1,cols+1)]
    return headings

def make_row(cols:int=10) -> list[float]:
    random.seed()
    my_row = [round(random.random()*10, 3) for _ in range(10)]
    my_row.insert(0, random.randrange(1, 200))
    my_row.insert(1, time.strftime("%H:%M:%S"))
    return my_row

def make_data(rows:int=10) -> list[list[float]]:
    my_data = [[data for data in make_row()] for _ in range(rows)]
    return my_data

def make_file(pathname:str, headings:list[str], my_data:list[list[float]]) -> bool:
    if not os.path.exists(pathname):
        with open(pathname, 'w', newline='') as newCSV:
            writer = csv.writer(newCSV, delimiter=",", quoting=csv.QUOTE_NONNUMERIC)
            writer.writerow(headings)
            writer.writerows(my_data)
        print(f"CSV data written to {pathname}.")
        return True
    else:
        print(f"Sorry, a med data file called '{pathname}' already exists, aborting!")
        return False

def build_me() -> None:
    print("Making headings")
    headings = make_headings()
    print("Making data")
    my_data = make_data(10)
    print("Creating filename")
    pathname = "MED_DATA_"+time.strftime("%Y%m%d%H%M%S")+".csv"
    print("Attempting to build the CSV med data file")
    result = make_file(pathname, headings, my_data)
    print(f"Written successfully: {result}")

for counter in range(5):
    print(f"nProcessing #{counter:3d}...")
    time.sleep(random.randint(1,5))
    build_me()

Buy Answer of This Assessment & Raise Your Grades

The following section details the rules provided by the CU Medical School regarding the medical data files structure and content.

Sample data – known issues

Unfortunately, medical data CSV files have had multiple issues in the past and this has led to communication regarding the variable quality of the data.

Common issues that CU’s School of Medicine have identified include:

  • Incorrectly formatted filenames.
  • Duplicated batch_ids in a single file
  • Missing headers or misspelt/incorrect headers, e.g. “batch” rather than “batch_id”
  • Missing columns on one or more rows
  • Invalid entries, e.g., reading values of 10 or greater
  • Invalid empty “0 byte” files (because there can be no “nil” returns)
  • Malformed files (causing difficulties when importing into other applications, e.g.,
    spreadsheets, databases, cloud-based machine learning etc.)

Sample data – Comma Separated Value (CSV) format

As noted, the University’s partner trial data is exported from proprietary medical devices as CSV files, which should follow rfc4180 guidelines, cf. https://tools.ietf.org/html/rfc4180

For example, a valid trial data CSV file, in raw form:

"batch_id","timestamp","reading1","reading2","reading3","reading4","reading5","rea
ding6","reading7","reading8","reading9","reading10"
55,"14:01:04",9.875,9.138,1.115,8.006,3.84,4.952,9.038,1.046,2.179,8.701
64,"14:01:04",4.168,9.247,1.958,1.65,3.631,9.317,8.182,9.292,5.978,3.06
116,"14:01:04",2.253,9.489,6.534,8.601,7.397,5.096,8.501,0.541,4.263,8.465
74,"14:01:04",0.89,5.942,3.02,9.526,8.478,7.84,1.85,8.81,4.712,6.805
142,"14:01:04",8.872,7.109,1.453,0.005,8.102,1.598,8.25,5.257,6.01,2.153
129,"14:01:04",2.115,7.738,4.946,7.444,6.362,5.735,9.768,6.25,5.32,4.073
113,"14:01:04",2.25,3.428,2.914,6.452,5.189,2.858,5.935,3.574,7.477,1.61
32,"14:01:04",1.956,6.395,7.196,2.823,2.563,1.305,7.938,6.421,0.398,3.024
172,"14:01:04",2.814,4.611,4.866,9.033,2.711,0.765,7.837,5.17,5.802,0.92
192,"14:01:04",0.539,0.103,1.669,7.162,0.912,7.134,2.151,7.439,6.612,6.731

And viewed in Microsoft Excel:

Filename convention

Filenames from the partner’s trial data exports are meant to be created using the following naming convention:

MED_DATA_YYYYMMDDHHMMSS.csv

For example:

MED_DATA_20230603140104.csv

This would represent a trial data .csv file that was created at 2:01:04 pm on 03/06/2023.

Buy Answer of This Assessment & Raise Your Grades

Batches

Each batch of results is identified by a unique batch_id (see 1st field) and this may appear unsorted in any .csv file. However, duplication of the same batch_id within a single file would indicate a faulty .csv file and this file should be both logged and excluded from further study, i.e. not stored by the University’s Medicine School.

In reality, batches within a single file may be exported within the same second or over multiple seconds, depending on throughput of the scientific partner’s proprietary devices, i.e. multiple entries for the same timestamp are not considered unusual.

Data Range

Each and every batch must have 10 readings.

All 10 readings should be represented as floating point numbers, formatted up to three decimal places with no value exceeding 9.9 (as this would be considered invalid data).

Task 1

Before starting the development for the CEA, Luzo Okake, CEO of the studio has asked you to prepare a primer document for the testing framework and methodology you intend to use. Doing so will enable new Testers to gain an insight into the concepts and processes involved when tackling this type of project.

This document should cover:

  • An identification of the objectives of testing.
  • A description of how testing is implemented in different SDLCs.
  • A description of the different objectives of TDD and BDD.
  • An explanation of why independent tests may prove beneficial to a software project’s
    success.

Extension activities:

To achieve a Merit, Luko wants you to compare functional and non-functional testing, including the various types of test performed in each.

Learning outcomes and assessment criteria

LO1 1.1, 1.2, 1.3, 1M1

Task 2

Luzo Okake has recommended the development team adopts a TDD approach to the software development lifecycle, particularly as the validation of each CSV data file can be broken down into a sequence of discrete validation checks.

Therefore, you should add the following content to the primer:

  • A description of the key aspects of TDD.
  • An explanation of black box and white box testing – to clear up any confusion.
  • A description of the different types of functional testing available and their associated objectives, i.e. what is being proven/disproven?

Extension activities:

To achieve a Merit, Luko wants you to create and execute a TDD plan for the submitted Python script, i.e. document how the sample script should have been created using these  principles.

To achieve a Distinction, Luko wants you to evaluate the robustness of the TDD plan you have created and executed. You must be able to identify any error, defects, or failures.

Learning outcomes and assessment criteria

LO2 2.1, 2.2, 2.3, 2M1, 2D1

Task 3

Luzo Okake has recommended that the testing team could implement a BDD process to test the behaviour of the Python script developed by the studio’s sub-team. However, before doing so, he has requested that you should add the following content to the primer:

  • A description of the key aspects of BDD.
  • A description of a DSL using suitable examples drawn from the Python script provided, focusing on expected vs. actual behaviours.

Extension activities:

To achieve a Merit, Luko has suggested that you should now create and execute a BDD plan for the submitted Python script.

To achieve a Distinction, Luko wants you to evaluate the robustness of the BDD plan you have created and executed. You must be able to identify any unexpected behaviours, performance levels and outcomes.

Learning outcomes and assessment criteria

LO3 3.1, 3.2, 3M1, 3D1

Are You Looking for Answer of This Assignment or Essay

The post ATHE Level 4 Unit 15 Software Testing Frameworks Assignment: TDD and BDD Strategy for Medical Data Validation Script in Python appeared first on Students Assignment Help UK.

📘 Stuck on Your Homework? We’ve Got You!

X