3.3.4 The project shall ensure that the software code is unit tested per the plans for software testing. NPR 7150.2, NASA Software Engineering Requirements, does not include any notes for this requirement. Classes F and G are labeled with "X (not OTS)." This means that this requirement does not apply to off-the-shelf software for these classes. Class D Not Safety Critical is labeled with "P (Center)." This means that an approved Center-defined process which meets a non-empty subset of the full requirement can be used to achieve this requirement. Class A_SC A_NSC B_SC B_NSC C_SC C_NSC D_SC D_NSC E_SC E_NSC F G H Applicable? P(C) X X Key: A_SC = Class A Software, Safety-Critical | A_NSC = Class A Software, Not Safety-Critical | ... | - Applicable | - Not Applicable Unit testing is the process for testing the range of inputs to a unit to ensure that only the intended outputs are produced. By doing this at the lowest level, fewer issues will be discovered when the components are later integrated and tested as a whole. Therefore, during unit testing, it is important to check the maximum and minimum values, invalid values, empty and corrupt data, etc. for each input and output to ensure the unit properly handles the data (processes or rejects it). Unit testing can be described as the confirmation that the unit performs the capability assigned to it, correctly interfaces with other units and data, and represents a faithful implementation of the unit design 081. Ensuring that developers perform unit testing in accordance with written test plans helps build quality into the software from the beginning and allows bugs to be corrected early in the project life cycle when such corrections cost the least to the project. Per IEEE STD 610.12-1990, IEEE Standard Glossary of Software Engineering Terminology, a "unit" is defined as: Projects ensure that the appropriate test environment, test materials, and personnel training (SWE-017), are in place and then conduct unit tests per the approved plans (SWE-104), according to the schedule (SWE-016), and with proper monitoring per the software assurance plan, making sure that: Per NASA-STD-8719.13, NASA Software Safety Standard; and NASA-GB-8719.13, NASA Software Safety Guidebook, software assurance is to "Verify unit testing and data verification is completed before the unit is integrated." 271 Either software assurance or Independent Verification and Validation (IV&V) personnel "Verify unit tests adequately test the software and are actually performed." 276 When less formal confirmation of unit testing is needed, a software team lead or other designated project member may verify completeness and correctness of the testing by comparing the results to the test plan to ensure that all logic paths have been tested and verifying the test results are accurate. 047 Unit testing tools and some integrated development environments (IDEs) can auto-generate unit tests based on the code. These tools provide a quick method to generate unit tests, but may not completely exercise the unit of code. Rerun units tests each time the unit is updated to ensure the code continues to work as expected. When continuous integration is part of the life cycle, all of the unit tests are rerun each time the code is updated to ensure only working code is integrated. Documented test results, results evaluations, issues, problem reports, corrections, and tester notes can all serve as evidence that unit tests were completed. Comparing those documents to the software test plans for unit testing can ensure the tests were completed in accordance with those documented procedures. Make sure evidence of all test passes is captured. NASA-GB-8719.13, NASA Software Safety Guidebook, 276 further states in the section on safety-critical unit test plans that "documentation is required to prove adequate safety testing of the software." Therefore, unit test results can play an important role in supporting reviews of safety-critical software. Consult Center PALs for Center-specific guidance and resources related to unit testing. Additional guidance related to unit testing may be found in the following related requirements in this handbook: Perform Testing Verify Implementation Document Defects and Track Software Test Plan Software Test Report Projects with limited budgets and personnel may choose to perform unit testing or capture unit test results and artifacts in a less formal manner than projects with greater resources. Regardless of the formality of the procedures used, the software test plans for unit testing need to describe the test environment/setup, results capture, simple documentation procedures, and compliance checks against the procedures. Some Centers have tailored lean unit test procedures and support tools specifically for small projects. Tools to aid in compliance with this SWE, if any, may be found in the Tools Library in the NASA Engineering Network (NEN). NASA users find this in the Tools Library in the Software Processes Across NASA (SPAN) site of the Software Engineering Community in NEN. The list is informational only and does not represent an “approved tool list”, nor does it represent an endorsement of any particular tool. The purpose is to provide examples of tools being used across the Agency and to help projects and centers decide what tools to consider. The NASA Lessons Learned database contains the following lessons learned related to unit testing:
See edit history of this section
Post feedback on this section
1. Requirements
1.1 Notes
1.2 Applicability Across Classes
X - Applicable with details, read above for more | P(C) - P(Center), follow center requirements or procedures2. Rationale
3. Guidance
(1) A separately testable element specified in the design of a computer software component.
(2) A logically separable part of a computer program.
(3) A software component that is not subdivided into other components.
Given the low-level nature of a unit of code, the person most able to fully test that unit is the developer who created it. 4. Small Projects
5. Resources
5.1 Tools
6. Lessons Learned
SWE-062 - Unit Test
Web Resources
View this section on the websiteUnknown macro: {page-info}