Commit c60d66d
authored
Introduce the require dsl. For when you need the assertion to pass before continuing (#1103)
* Introduce the require-dsl. expect, but it returns the result of the expression
As implied, this is basically a copy-paste of the functionality of expect. It's not complete, and it's not well-tested. But it gets the idea across.
Future work is cleaning this up, backfilling tests for features (such as the unwrap function), and adding support for polling requirements (i.e. toEventually).
Other than functionality, require also files the errorThrown issue type with XCTest, whereas expect files the assertionFailed issue type. This has minor differences that are mostly semantics.
Also, in addition to the require dsl, this also adds unwrap, which is a shorthand for `require(...).toNot(beNil())`.
* Backfill some tests for requirement
Support async, but not yet polling.
* CustomNSError is only defined in Foundation
* Support polling using require
Oh, gosh. This is terrible. I think a cleaner way to do this would be to change MatcherResult to also store the most recent value.
But that would be a breaking change, and might require updating existing matchers, so... no.
* require should allow you to discard the result
Rename requireAsync to requirea - matching the example set forth by expecta.
Adds requires, which is requirea, but for specifying SyncRequirement.
* Document require in the README
Update the table of contents with doctoc.
* Remove AssertionHandler.require., require matcher failures will be recorded as test assertion failures, which is what they are anyway.
* backfill tests for pollUnwrap
Also actually mark the non-polling require dsl as discardableResult
* Mark Expectation.onFailure as deprecated in favor of the require dsl
* Rename RequirementError to RequireError
Fixed test failure on linux
* Allow passing a custom error to be thrown by require
* Update readme TOC1 parent ef552dc commit c60d66d
11 files changed
Lines changed: 2004 additions & 11 deletions
File tree
- Nimble.xcodeproj
- Sources/Nimble
- Tests/NimbleTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
128 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
| |||
310 | 315 | | |
311 | 316 | | |
312 | 317 | | |
| 318 | + | |
| 319 | + | |
313 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
314 | 324 | | |
315 | 325 | | |
316 | 326 | | |
| |||
448 | 458 | | |
449 | 459 | | |
450 | 460 | | |
| 461 | + | |
451 | 462 | | |
452 | 463 | | |
453 | 464 | | |
454 | 465 | | |
455 | 466 | | |
456 | 467 | | |
457 | 468 | | |
| 469 | + | |
| 470 | + | |
458 | 471 | | |
459 | 472 | | |
460 | 473 | | |
| |||
470 | 483 | | |
471 | 484 | | |
472 | 485 | | |
| 486 | + | |
473 | 487 | | |
474 | 488 | | |
475 | 489 | | |
476 | 490 | | |
| 491 | + | |
477 | 492 | | |
478 | 493 | | |
479 | 494 | | |
| |||
959 | 974 | | |
960 | 975 | | |
961 | 976 | | |
| 977 | + | |
962 | 978 | | |
963 | 979 | | |
964 | 980 | | |
| |||
968 | 984 | | |
969 | 985 | | |
970 | 986 | | |
| 987 | + | |
971 | 988 | | |
972 | 989 | | |
| 990 | + | |
973 | 991 | | |
974 | 992 | | |
975 | 993 | | |
| |||
1038 | 1056 | | |
1039 | 1057 | | |
1040 | 1058 | | |
| 1059 | + | |
1041 | 1060 | | |
1042 | 1061 | | |
1043 | 1062 | | |
| |||
1046 | 1065 | | |
1047 | 1066 | | |
1048 | 1067 | | |
| 1068 | + | |
1049 | 1069 | | |
1050 | 1070 | | |
1051 | 1071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
39 | 52 | | |
40 | 53 | | |
41 | 54 | | |
| |||
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
| 65 | + | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
| |||
61 | 76 | | |
62 | 77 | | |
63 | 78 | | |
| 79 | + | |
64 | 80 | | |
65 | 81 | | |
66 | | - | |
67 | 82 | | |
68 | 83 | | |
69 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
70 | 88 | | |
71 | 89 | | |
72 | 90 | | |
| |||
677 | 695 | | |
678 | 696 | | |
679 | 697 | | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
680 | 781 | | |
681 | 782 | | |
682 | 783 | | |
| |||
0 commit comments