Marketers and developers work together on a regular basis — to update apps, launch new technology solutions and more. One area that might keep tech-averse marketers up at night is establishing a unit test, which acts as a verification of a code function. While unit tests were typically the purview of developers, marketers should be aware of the methodologies developers use in unit tests to ensure they will not impact how customer data privacy and data models are managed.
Let's take a look at the basics of a unit test to help understand what's at stake and how marketers can get involved.
What Is a Unit Test?
Unit tests are a section of code that validates the functions and variables in a program to confirm it operates as intended. In other words, does a tested input produce the expected output. A unit test contains one concept to test and one assertion to verify. It then verifies that the inputs fit for most of the program's use cases. The validation ensures developers avoid changes that inadvertently introduce code errors.
A simple example: you want to launch an app update, and you need it to optimize data. To know if its needs to optimize data further, we want our data to produce a mean standard error within a range of negative 0.5 and 0.5. The range is based on past experience on the previous app which provided a robust service for customers. In a program, the calculation output is placed in a unit test that alerts you whether or not the desired range is met.
To show this, I am using a function to calculate a mean standard error in R programming. The image below shows the program in an IDE called RStudio. The first eight lines create a linear regression, followed by a mean standard error calculation on line eight. The test itself occurs on lines 11 through 14, using a function in R programming to test if the variable from line 8, e, fits within a tolerance of negative 0.5 and 0.5. The test is set up to issue a message if the mean standard error falls within our desired range. You can see the message at the top of the image.
Developers typically plan and write unit tests before creating the overall program. This lets developers think out the if-then scenario of test results. A test answers if one specific line of code or calculation is a pass or failure. A range of conditions can be applied for a pass or fail. This approach quickly reveals small defects in a program or outliers of logic in a calculation.
Each programming language has a unit test framework. For data modeling, R programming has a library called testThat. The library provides a number of test functions to apply. Python, which is also frequently used for predictive analytics and machine learning data, has a similar library called PyTest.
Related Article: How Marketers Can Use Regressions for Better Machine Learning Initiatives
Involving Marketing Insight for Development and Privacy Insights
You may have guessed from the example above where marketers come in here. Marketers can provide meaningful support for unit tests by outlining the user experience for a website or app relative to the data generated. This doesn't require knowledge of technical syntax. Marketers can help guide which criteria to apply to establish the pass or fail in the unit test by documenting expectations. For app development, the input can influence how to best refactor the program. Refactoring is optimizing the code without changing the functionality. Usually developer teams decide this, but it can help with what a final production app should produce for code maintainability and quality.
The support and documentation can help support privacy compliance for data used in a program. Privacy legislation like GDPR requires companies to document any key decisions on how compliance is maintained. Some of those decisions, like the kind of data inputted into a solution or app, require testing to ensure that unwanted data is not inadvertently introduced. A unit test can be set up to catch characters commonly associated with personal identifiable information. Such tests often serve as quality assurance steps to make sure adherence to the specifications set. The kind of test chosen for QA can vary, such as having a video created to capture a programming bug in play. Whatever form it takes, it ultimately should place someone’s eyeballs on the program and its output to ensure compliance.
A common danger in software development planning occurs when tests are scheduled towards the end of a development workflow, after sketching out the program specification and code. This timing makes unit testing vulnerable to development budget cuts when money is tight. It is easier at this point to justify stopping or even avoiding the tests altogether due to budget constraints. To correct this, developers often plan tasks according to methodologies such as Test Driven Development (TDD) and Behavioral Driven Development (BDD). Each framework rearranges a given workflow to conduct tests earlier in the process. Marketer involvement here comes in the form of support for these approaches to data-related designs. Ensuring the testing falls earlier in the process adheres to good governance practices and helps organizations avoid costly privacy mistakes down the line.
Related Article: GDPR Compliance Requires Looking at the Big Customer Data Picture
Use Unit Tests to Protect Privacy as Well as Solution Quality
Discussions on unit testing may feel outside of the marketing wheelhouse. But marketing input into tests can guide developers on what boundaries are vital to customer experience and to protect the quality of data the app uses. With data now a central element in apps and solutions supporting business operations, that discussion can help managers better ensure operational quality and data privacy.