  Software safety is a crucial aspect during the development of modern
safety-critical systems. Software is becoming responsible for most of the
critical functions of systems. Therefore, the software components in the
systems need to be tested extensively against their safety requirements to
ensure a high level of system safety. However, performing testing exhaustively
to test all software behaviours is impossible. Numerous testing approaches
exist. However, they do not directly concern the information derived during the
safety analysis. STPA (Systems-Theoretic Process Analysis) is a unique safety
analysis approach based on system and control theory, and was developed to
identify unsafe scenarios of a complex system including software. In this
paper, we present a systematic and semi-automatic testing approach based on
STPA to generate test cases from the STPA safety analysis results to help
software and safety engineers to recognize and reduce the associated software
risks. We also provide an open-source safety-based testing tool called STPA
TCGenerator to support the proposed approach. We illustrate the proposed
approach with a prototype of a software of the Adaptive Cruise Control System
(ACC) with a stop-and-go function with a Lego-Mindstorms EV3 robot.
