VBA-tools / vba-test

Add testing and TDD to VBA on Windows and Mac
MIT License
202 stars 46 forks source link

Update Workbook proxy #6

Open timhall opened 9 years ago

timhall commented 9 years ago

Tasks:

BeforeEach and AfterEach goal:

Dim Proxy As New WBProxy
' Initial setup/mapping...

Suite.BeforeEach "Setup", Instance:=Proxy
Suite.AfterEach "Teardown", Instance:=Proxy

Causes an issue with current arguments implementation, since ParamArray cannot be used with other Optional variables (Instance), but ByRef with BeforeEach and AfterEach is a goal, so ParamArray might not be useful anyways.

timhall commented 6 years ago

This seems much more likely with the evented approach used in v2 and the Context object proposed in #23 so this is seeming much more straightforward. Basically, it will open / copy the workbook before each test, pass it in as .Context("workbook"), and close the workbook without saving after each test.

Dim Suite As New TestSuite

Dim Fixture As New WorkbookFixture
Fixture.Open "path/to/workbook.xlsm"
Fixture.ListenTo Suite

With Suite.Test("should open workbook")
  .IsEqual .Context("workbook").Name, "workbook"
End With