From 6438587a24f76e76fc350dcf94f72e238167c74a Mon Sep 17 00:00:00 2001 From: Marcio Souza Duarte Date: Tue, 24 Aug 2021 14:55:37 -0300 Subject: [PATCH] add color in test 1 --- .gitignore | 2 ++ parte_1/DiscountCalculatorTest.php | 13 ++++++++----- parte_1/run_tests.php | 7 ++++++- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f4acd3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor/ +composer.lock \ No newline at end of file diff --git a/parte_1/DiscountCalculatorTest.php b/parte_1/DiscountCalculatorTest.php index 13566b2..60095cb 100755 --- a/parte_1/DiscountCalculatorTest.php +++ b/parte_1/DiscountCalculatorTest.php @@ -2,7 +2,8 @@ class DiscountCalculatorTest { - public function ShouldApply_WhenValueIsAboveTheMinimumTest() { + public function ShouldApply_WhenValueIsAboveTheMinimumTest() + { $discountCalculator = new DiscountCalculator(); @@ -13,7 +14,8 @@ public function ShouldApply_WhenValueIsAboveTheMinimumTest() { $this->assertEquals($expectedValue, $totalWithDiscount); } - public function ShouldNotApply_WhenValueIsBellowTheMinimumTest() { + public function ShouldNotApply_WhenValueIsBellowTheMinimumTest() + { $discountCalculator = new DiscountCalculator(); @@ -24,13 +26,14 @@ public function ShouldNotApply_WhenValueIsBellowTheMinimumTest() { $this->assertEquals($expectedValue, $totalWithDiscount); } - public function assertEquals($expectedValue, $actualValue) { + public function assertEquals($expectedValue, $actualValue) + { if ($expectedValue !== $actualValue) { $message = 'Expected: ' . $expectedValue . ' but got: ' . $actualValue; throw new \Exception($message); } - echo "Test passed! \n"; + echo "\e[0;32;40mTest passed!\e[0m\n"; } -} \ No newline at end of file +} diff --git a/parte_1/run_tests.php b/parte_1/run_tests.php index 65d2b96..948dd42 100755 --- a/parte_1/run_tests.php +++ b/parte_1/run_tests.php @@ -18,6 +18,11 @@ continue; } - $testClass->$method(); + try { + echo "\e[1;33;40m" . $method . ":\e[0m "; + $testClass->$method(); + } catch (\Exception $e) { + echo "\e[0;31;40m" . $e->getMessage() . "\e[0m\n"; + } } }