# Statement Coverage **Published by:** [guanbinrui.eth](https://paragraph.com/@guanbinrui/) **Published on:** 2022-03-21 **URL:** https://paragraph.com/@guanbinrui/statement-coverage ## Content Statement Coverage Formula number of executed statements ------------------------------- total number of statements Source print_sum(int a, int b) { int result = a + b; if (result > 0) { println("%s", "red"); } else if (result < 0) { println("%s", "blue"); } } TC #1 Input: a = 3, b = 9 Coverage: 7 / 9 = 77.8% ✅ print_sum(int a, int b) { ✅ int result = a + b; ✅ ✅ if (result > 0) { ✅ println("%s", "red"); ❌ } else if (result < 0) { ❌ println("%s", "blue"); ✅ } ✅ } TC #2 Input: a = -5, b = -8 Coverage: 8 / 9 = 88.9% ✅ print_sum(int a, int b) { ✅ int result = a + b; ✅ ✅ if (result > 0) { ❌ println("%s", "red"); ✅ } else if (result < 0) { ✅ println("%s", "blue"); ✅ } ✅ } ## Publication Information - [guanbinrui.eth](https://paragraph.com/@guanbinrui/): Publication homepage - [All Posts](https://paragraph.com/@guanbinrui/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@guanbinrui): Subscribe to updates