-
Couldn't load subscription status.
- Fork 315
Closed
Labels
bugIdentifies work items for known bugsIdentifies work items for known bugscriticalMarks a bug as a must-fix, showstopper issueMarks a bug as a must-fix, showstopper issuefeature-unit-testing
Milestone
Description
The following unit test for Fakes.InputBox.ReturnsWhen fails. Same happens for MsgBox, other Fakes not tested.
'@TestMethod
Public Sub InputBoxFakeReturnsWhenWorks()
On Error GoTo TestFail
Dim userInput As String
Fakes.InputBox.ReturnsWhen "prompt", "Dummy1", "dummy1 user input"
Fakes.InputBox.ReturnsWhen "prompt", "Expected", "expected user input"
Fakes.InputBox.ReturnsWhen "prompt", "Dummy2", "dummy2 user input"
userInput = InputBox(prompt:="Expected")
'Assert fails: userInput is "dummy1 user input"
Assert.AreEqual "expected user input", userInput
TestExit:
Exit Sub
TestFail:
Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description
End Sub
Hardcoding the invocation number for the "Expected" input box makes the test pass:
Fakes.InputBox.ReturnsWhen "prompt", "Dummy1", "dummy1 user input"
Fakes.InputBox.ReturnsWhen "prompt", "Expected", "expected user input", 1
Fakes.InputBox.ReturnsWhen "prompt", "Dummy2", "dummy2 user input"
But hardcoding the others to 1, too, makes it fail and userInput is "dummy1 user input" again:
Fakes.InputBox.ReturnsWhen "prompt", "Dummy1", "dummy1 user input", 1
Fakes.InputBox.ReturnsWhen "prompt", "Expected", "expected user input", 1
Fakes.InputBox.ReturnsWhen "prompt", "Dummy2", "dummy2 user input", 1
Rubberduck version: Version 2.1.2.2738
Operating System: Microsoft Windows NT 10.0.14393.0, x64
Host Product: Microsoft Office 2016 x64
Host Version: 16.0.8431.2131
Host Executable: EXCEL.EXE
Metadata
Metadata
Assignees
Labels
bugIdentifies work items for known bugsIdentifies work items for known bugscriticalMarks a bug as a must-fix, showstopper issueMarks a bug as a must-fix, showstopper issuefeature-unit-testing