New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assert.SequenceEquals Not Working as Expected? #4385
Comments
By default, the We have also implemented the |
Does this change anything (assuming the
|
That test is essentially a "poor man's data-driven test" working around lack of data-driven support for Rubberduck unit tests (#1229). An alternative work-around could be to split it into multiple tests that explicitly cover a single case, for example: '@TestMethod
Public Sub GivenSameDividendAndDivisor_RemainderIsZero()
Const value As Double = 10
Const expected As Double = 0
If value = 0 Then
Assert.Inconclusive "Test is misconfigured"
Exit Sub
End If
Dim actual As Double
actual = Arithmetic.Remainder(value, value)
Assert.AreEqual expected, actual
End Sub
'@TestMethod
Public Sub GivenNegativeDividendPositiveDivisor_RemainderIsNegative()
Const dividend As Double = -5
Const divisor As Double = 2
If dividend >= 0 Or divisor <= 0 Then
Assert.Inconclusive "Test is misconfigured"
Exit Sub
Else
Dim actual As Double
actual = Arithmetic.Remainder(dividend, divisor)
Assert.IsTrue actual < 0
End If
End Sub
'@TestMethod
Public Sub GivenPositiveDividendNegativeDivisor_RemainderIsPositive()
Const dividend As Double = 5
Const divisor As Double = -2
If dividend <= 0 Or divisor >= 0 Then
Assert.Inconclusive "Test is misconfigured"
Exit Sub
Else
Dim actual As Double
actual = Arithmetic.Remainder(dividend, divisor)
Assert.IsTrue actual > 0
End If
End Sub
'@TestMethod
Public Sub GivenNegativeDividendAndDivisor_RemainderIsNegative()
Const dividend As Double = -5
Const divisor As Double = -2
If dividend >= 0 Or divisor >= 0 Then
Assert.Inconclusive "Test is misconfigured"
Exit Sub
Else
Dim actual As Double
actual = Arithmetic.Remainder(dividend, divisor)
Assert.IsTrue actual < 0
End If
End Sub
'@TestMethod
Public Sub GivenZeroDivisor_ThrowsInvalidArgument()
Const expectedError As Long = 5 'invalid procedure call or argument
On Error GoTo TestFail
Const dividend As Double = -5
Const divisor As Double = 0
If divisor <> 0 Then
Assert.Inconclusive "Test is misconfigured"
Exit Sub
End If
Dim actual As Double
actual = Arithmetic.Remainder(dividend, divisor)
Assert:
Assert.Fail "Expected error was not raised."
TestExit:
Exit Sub
TestFail:
If Err.Number = expectedError Then
Resume TextExit
Else
Resume Assert
End If
End Sub |
I considered splitting the test in several smaller tests, but since this is a rather simple function in a rather extensive Arithmetic class, I decided to try and keep all test cases as compact as possible. Anyway, this worked:
Thanks Mathieu. By the way, nice idea the one you have going on for supporting data-driven tests! |
Hi Rubberduck team. I have this test case:
If I uncomment the
Assert.SequenceEquals
line (and comment the previousFor
block in the Assert section of the case), the test fails. But it passes if I run it as it's presented above.Is this a bug? Am I missing something in the Arrange or Act sections? I tried looking at the documentation, but couldn't find anything useful to help me figure it out for myself.
Thanks!
Version 2.2.0.3806
OS: Microsoft Windows NT 10.0.17134.0, x64
Host Product: Microsoft Office x86
Host Version: 16.0.10730.20102
Host Executable: EXCEL.EXE
The text was updated successfully, but these errors were encountered: