Rubberduck: Fakes API docs?

Created on 18 Dec 2017  路  4Comments  路  Source: rubberduck-vba/Rubberduck

Hello all. Thanks for doing such a great job on such a useful add-in. Having used it for a couple of months I find that I can't go back to the "old" way!

I have some message boxes in my code that I need to Fake but I can't, for the life of me, find any docs on how to fake these. Can you point me in the right direction or am I going to have to study the code to figure it out?

Thanks in advance!

feature-fakes feature-unit-testing support up-for-grabs user-documentation

Most helpful comment

As soon as I figure out how to implement it I would be very happy to contribute docs. Let me wrestle with it for a while and I'll start plunking away...

All 4 comments

Thanks for your feedback! We've yet to document (and complete) the API, but there is a RD News post that announces the feature and illustrates how the API works:

Go ahead, mock VBA

'@TestMethod
Public Sub TestMethod1()
    On Error GoTo TestFail

    Fakes.MsgBox.Returns 42
    Debug.Print MsgBox("Flabbergasted yet?", vbYesNo, "Rubberduck") 'prints 42

    With Fakes.MsgBox.Verify
        .Parameter "prompt", "Flabbergasted yet?"
        .Parameter "buttons", vbYesNo
        .Parameter "title", "Rubberduck"
    End With
TestExit: 
    Exit Sub
TestFail: 
    Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description
End Sub

That Debug.Print statement would be the "act" part of your test, where you invoke the code that needs MsgBox calls hijacked.

You'll find the source code under the Rubberduck.UnitTesting namespace.

Hope it helps!

I鈥檓 just going to throw this out here FWIW.
Every FLOSS project ever always needs help with documentation.
Our wiki is open for editing.
We would greatly appreciate it if anyone donated some time to creating some docs around this feature.

wink wink nudge nudge

As soon as I figure out how to implement it I would be very happy to contribute docs. Let me wrestle with it for a while and I'll start plunking away...

In all seriousness, there鈥檚 no pressure, but we would appreciate it if you decide to.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThunderFrame picture ThunderFrame  路  3Comments

bclothier picture bclothier  路  3Comments

retailcoder picture retailcoder  路  4Comments

retailcoder picture retailcoder  路  3Comments

connerk picture connerk  路  3Comments