Skip to content

Migrate from using unittest package to the test package#5

Open
Stargator wants to merge 4 commits into
polux:masterfrom
Stargator:update-tests
Open

Migrate from using unittest package to the test package#5
Stargator wants to merge 4 commits into
polux:masterfrom
Stargator:update-tests

Conversation

@Stargator

Copy link
Copy Markdown
Contributor

Part of a larger effort to migrate to Dart 2, but figured I would separate out the efforts.

@polux polux left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the update, but could you please revert the try-catch as commented?

Comment thread example/demo.dart Outdated
test('bad', () => sc.check(badProperty));

test('bad', () {
try {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of demo.dart is to show that if you write unit tests that way, they will fail when your property is violated. The goal is for the user to run dart example/demo.dart and to observe the output on the console to get a feeling of what it is like to use the lib. So I'd rather not catch the exceptions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I don't catch the error, then the test fails. I figured that was due to the unittest API at the time not having a way to expect an error to be thrown.

I tried expect(sc.check(badProperty), throwsA(equals('falsified after 11 tests\n' ' argument 1: [true]\n' ' argument 2: [false]\n' ''));

But I couldn't get it to work as expected (no pun intended).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is that demo.dart is not a test of the propcheck library. Instead it is a file meant to showcase the library and its tests fail on purpose to showcase the error messages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then I think I did the try-catch before I realized enumerators need to be updated. Once that is done, I can retest this propcheck branch to ensure nothing broke (at least according to the tests).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this is the error that occurs when I run demo.dart. I added it to a gist with a version of the output from the master branch for comparison.

@polux polux left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for the nit. Once it's fixed I'll merge the change. Thanks again!

Comment thread example/demo.dart
group('smallcheck', () {
final sc = new SmallCheck(depth: 10);
test('good', () => sc.check(goodProperty));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you please drop this newline? (Same below.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants