Skip to content

Commit

Permalink
Merge pull request #6 from samuelematias/lesson6
Browse files Browse the repository at this point in the history
Lesson 6
  • Loading branch information
samuelematias committed Dec 2, 2020
2 parents 94696fc + f675652 commit bb27a9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Calculator - [Caster.IO](https://caster.io) project to showcase testing techniqu

[Lesson 5: Using expect() in your tests](https://caster.io/lessons/lesson-5-using-expect-in-your-tests) 👉🏾 [Branch](https://github.com/samuelematias/calculator_app/tree/lesson5)

[Lesson 6: All you need to know about Matchers](https://caster.io/lessons/lesson-6-all-you-need-to-know-about-matchers) 👉🏾 [Branch](https://github.com/samuelematias/calculator_app/tree/lesson6)

## License

```
Expand Down
12 changes: 10 additions & 2 deletions packages/calculator/test/calculator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ import 'package:calculator/calculator.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
test('Calculator creates a non null object', () {
expect(Calculator(), isNotNull);
});

test('the calculator returns an double number when adding 2 and 2', () {
final calculator = Calculator();
final result = calculator.add(2, 2);
expect(result, isA<double>());
});

test('the calculator returns 4 when adding 2 and 2', () {
final calculator = Calculator();
final result = calculator.add(2, 2);
// A test without expect() is considered a bad practice
// in case of error, this "reason" text, will show on stacktrace.
expect(result, 4.00000, reason: 'It should be exactly 4');
});
}

0 comments on commit bb27a9f

Please sign in to comment.