You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -37,68 +38,31 @@ Public Function Add(ParamArray Values() As Variant) As Double
37
38
Nexti
38
39
EndFunction
39
40
40
-
' Open the Immediate Window (Ctrl+g or View > Immediate Window) and Run Specs (F5)'
41
-
' = PASS (2 of 2 passed) ==========================
41
+
' Immediate Window:
42
+
'
43
+
' === Add ===
44
+
' + should add two numbers
45
+
' + should add any number of numbers
46
+
' = PASS (2 of 2 passed) =
42
47
```
43
48
44
-
For details of the process of reaching this example, see the [TDD Example](https://github.com/timhall/Excel-TDD/wiki/TDD-Example)
49
+
For details of the process of reaching this example, see the [TDD Example](https://github.com/VBA-tools/VBA-TDD/wiki/TDD-Example)
45
50
46
51
### Advanced Example
47
52
48
-
For an advanced example of what is possible with Excel-TDD, check out the [specs for Excel-REST](https://github.com/timhall/Excel-REST/tree/master/specs)
49
-
50
-
Methods used in these specs:
51
-
52
-
- Using `BeforeEach` to reset before each spec is run
53
-
- Testing VBA modules and classes
54
-
- Setting up a custom `DisplayRunner` and `InlineRunner`
55
-
- Waiting for and handling async behavior
53
+
For an advanced example of what is possible with VBA-TDD, check out the [specs for VBA-Web](https://github.com/VBA-tools/VBA-Web/tree/master/specs)
56
54
57
55
### Getting Started
58
56
59
-
For testing macros:
60
-
61
-
- The lightweight Inline Runner is recommended and should be added directly to the workbook that is being tested
62
-
- Add `InlineRunner.bas`, `SpecDefinition.cls`, `SpecExpectation.cls`, and `SpecSuite.cls` to your workbook
63
-
- If starting from scratch, the `Excel-TDD - Blank - Inline.xlsm` workbook includes all of the required classes and modules
64
-
65
-
For testing workbooks:
66
-
67
-
- The full Workbook Runner is recommended in order to keep testing behavior separate from the workbook that is being tested
68
-
- Use the `Excel-TDD - Blank.xlsm` workbook
69
-
- See the [Workbook Runner Example](https://github.com/timhall/Excel-TDD/wiki/Workbook-Runner-Example) for details
70
-
71
-
### Inline Runner
72
-
73
-
The inline runner is a lightweight test runner that is intended to be loaded directly into the workbook that is being tested and is for testing macros and simple behaviors in the workbook
74
-
All results are displayed in the Immediate Window (Ctrl+g or View > Immediate Window) and the runner requires no setup to run test suites
75
-
76
-
```VB.net
77
-
InlineRunner.RunSuiteSpecs
78
-
79
-
' = PASS (2 of 2 passed) ==========================
' = PASS (2 of 2 passed) ==========================
85
-
' + 2 specs
86
-
' + should add two numbers
87
-
' + should add any number of numbers
88
-
' ===
89
-
```
90
-
91
-
### Workbook Runner
92
-
93
-
The workbook runner is a full test runner that is intended to be used separately of the workbook that is being tested to keep testing behavior separate.
94
-
It is for testing advanced workbook behaviors and allows for reseting the test workbook between tests, using scenarios for tests (see below), and running tests against different test workbooks.
95
-
See the [Workbook Runner Example](https://github.com/timhall/Excel-TDD/wiki/Workbook-Runner-Example) for details
57
+
1. Download the [latest release (v2.0.0-beta)](https://github.com/VBA-tools/VBA-TDD/releases)
58
+
2. Add `src/SpecSuite.cls`, `src/SpecDefinition.cls`, `src/SpecExpectation.cls`, add `src/ImmediateReporter.cls` to your project
59
+
3. If you're starting from scratch with Excel, you can use `VBA-TDD - Blank.xlsm`
96
60
97
61
### It and Expect
98
62
99
63
`It` is how you describe desired behavior and once a collection of specs is written, it should read like a list of requirements.
100
64
101
-
```VB.net
65
+
```vb
102
66
WithSpecs.It("should allow user to continue if they are authorized and up-to-date")
103
67
' ...
104
68
EndWith
@@ -110,7 +74,7 @@ End With
110
74
111
75
`Expect` is how you test desired behavior
112
76
113
-
```VB.net
77
+
```vb
114
78
WithSpecs.It("should check values")
115
79
.Expect(2+2).ToEqual4
116
80
.Expect(2+2).ToNotEqual5
@@ -155,7 +119,59 @@ With Specs.It("should test complex things")
155
119
EndWith
156
120
```
157
121
158
-
For more details, check out the [Wiki](https://github.com/timhall/Excel-TDD/wiki)
122
+
### ImmediateReporter
123
+
124
+
With your specs defined, the easiest way to display the test results is with `ImmediateReporter`. This outputs results to the Immediate Window (`ctrl+g` or View > Immediate Window) and is useful for running your tests without leaving the VBA editor.
125
+
126
+
```vb
127
+
PublicFunctionSpecsAsSpecSuite
128
+
SetSpecs=NewSpecSuite
129
+
Specs.Description="..."
130
+
131
+
' Create reporter and attach it to these specs
132
+
DimReporterAsNewImmediateReporter
133
+
Reporter.ListenToSpecs
134
+
135
+
' -> Reporter will now output results as they are generated
136
+
EndFunction
137
+
```
138
+
139
+
### RunMatcher
140
+
141
+
For VBA applications that support `Application.Run` (which is at least Windows Excel, Word, and Access), you can create custom expect functions with `RunMatcher`.
142
+
143
+
```vb
144
+
PublicFunctionSpecsAsSpecSuite
145
+
SetSpecs=NewSpecSuite
146
+
147
+
WithSpecs.It("should be within 1 and 100")
148
+
.Expect(50).RunMatcher"ToBeWithin","to be within",1,100
0 commit comments