Testing interviews often have the questions for the negative and positive test cases for traffic signal. In this post I am jotting down some of the test cases that you can use. If you have any questions and suggestions to improve this post then please do let me know. If you plan to share the content of this post on forums or blogs, then please do share the URL instead of copying the content from this site.
Before we write test cases for traffic signal, let’s first understand the lights.
- Red – stop and wait before the zebra crossing line.
- Green – go.
- Yellow – stop, unless – 1) you’ve already crossed the stop line after green light is off. 2) you’re so close to it that pulling up might cause an accident. 3) You’re in middle of the road and should move to next side rather than going back causing traffic problem.
Do note that traffic light has color variation for yellow signal. Some of the countries have that as amber or silver color. Some may even find the color different in order. So it all depends on which standard that is being followed for the traffic signal machine and country traffic rules. You may want to adjust the traffic rules as per the rules applied in your state or country. That would make the below test cases more accurate and effective.
That being said, here are the list of test cases for traffic signal.
- Check if the traffic lights are on during the expected traffic period as per rules.
- Check if the traffic lights timer works as per expected specific signal.
- Check if the traffic lights are displayed in sequential order.
- Check if the traffic light for stop signal is shown with red light.
- Check if the traffic light for wait unless signal is shown with yellow or amber color.
- Check if the traffic light for go is shown with green.
- Check if the traffic lights are one at a time.
- Check if the traffic lights during off hours show blinking yellow or amber color displaying off for rules.
- Check the time delay between the lights.
- Check the sequence of multiple signal posts are in sync in cross roads.
These are some of the test cases that we can use to test the traffic signal post. There are many other product specific test cases that we can develop. I hope the test cases in this post are helpful to you. Feel free to let me know if you have any questions or comments below 🙂