JasonEnsor
Programmer
Hi Guys,
I am trying to write some code to UnitTest some of my procedures in VBA and was looking for some suggestions on how best to improve my concept.
Currently I have a UnitTest class that takes in a TestName,ExpectedResults,ActualResults and TestDescription, I am then adding these to a UnitTests Collection so that I can then output them to a text document.
The code is in a very rough state at the moment but what I have so far is
I am only using the Description field at the moment so the tests are duplicated apart from that value. Am I right in having to create a new instance of UnitTest each time I want to add a UnitTest, I thought I could add the UnitTest to the collection then update the values and add that to the collection. however that doesn't seem to work.
The code above works but it doesn't seem very clean to me.
Am I missing something?
Regards
J.
Regards
J.
I am trying to write some code to UnitTest some of my procedures in VBA and was looking for some suggestions on how best to improve my concept.
Currently I have a UnitTest class that takes in a TestName,ExpectedResults,ActualResults and TestDescription, I am then adding these to a UnitTests Collection so that I can then output them to a text document.
The code is in a very rough state at the moment but what I have so far is
Code:
Global UnitTests As Collection
Public Sub testing()
Dim clss As New Class1
Set cls = New UnitTest
cls.TestName = "IsValidWorkbook"
cls.TestActualResult = IIf(clss.IsWorkbookValid(ThisWorkbook, "Sheet1"), "Pass", "Fail")
cls.TestDescription = "1st"
UnitTests.Add cls
Set cls = New UnitTest
cls.TestName = "IsValidWorkbook"
cls.TestActualResult = IIf(clss.IsWorkbookValid(ThisWorkbook, "Sheet1"), "Pass", "Fail")
cls.TestDescription = "2st"
UnitTests.Add cls
Call DisplayResults
End Sub
I am only using the Description field at the moment so the tests are duplicated apart from that value. Am I right in having to create a new instance of UnitTest each time I want to add a UnitTest, I thought I could add the UnitTest to the collection then update the values and add that to the collection. however that doesn't seem to work.
The code above works but it doesn't seem very clean to me.
Am I missing something?
Regards
J.
Regards
J.