Git Product home page Git Product logo

excelvbaunit's People

excelvbaunit's Issues

Fails with no useful info if wrong project name entered

What steps will reproduce the problem?
1. create MyXls.xls with VBA test code
2. do not change project from default VBAProject name
3. xrun "MyXls" fails with no indication of what error is

What version of the product are you using? On what operating system?
- Vista Business SP2 32 bit, Excel 2002 with VBA MSVB6.3

Please provide any additional information below.
rewrite GetTestFixtures as follows:
---------------------
Public Function GetTestFixtures(projectName As String) As TestFixture()

    Dim project As VBProject
    On Error GoTo e_GTF: ' << extra line
    Set project = Application.VBE.VBProjects(projectName)
    ' Project not found?

    ' Get list of modules containing test cases
    Dim components() As VBComponent
    components = GetTestingComponents(project)

    ' Each module corresponds to a fixture
    Dim fixtures() As TestFixture
    Dim count As Integer
    count = Main.SafeUbound(components)

    If count >= 0 Then
        ReDim fixtures(0 To count) As TestFixture

        Dim i As Integer
        For i = 0 To count
            Set fixtures(i) = New TestFixture
            fixtures(i).ExtractTestCases project, components(i)
        Next
    End If

    GetTestFixtures = fixtures
    Exit Function' << extra line
e_GTF:' << extra line
    For Each project In Application.VBE.VBProjects' << extra line
        Debug.Print project.name' << extra line
        Next' << extra line
    MsgBox (projectName + " not found in Application.VBE.VBProjects")' <<
extra line
    Stop' << extra line
End Function


Original issue reported on code.google.com by [email protected] on 28 May 2009 at 2:49

Error thrown if there are no modules with "Test" as the prefix or "Tester" as the suffix

What steps will reproduce the problem?
1. Create Test.xls and insert some VBA testing code
2. Do not name any of the modules with the prefix "Test" or the 
suffix "Tester"
3. Leave the project name as the default (VBAProject)
4. Type xRun "VBAProject" into the Immediate window and press Enter
5. Causes "Run-time error '9': Subscript is out of range" on the line "For 
i = 0 To UBound(fixtures)" in the SetUpResultsManager subroutine of the 
TestRunner class.

What is the expected output? What do you see instead?
Expected output of "Total: 0 passes, 0 failures" in the Immediate window.

What version of the product are you using? On what operating system?
- excelvbaunit Revision 13
- Excel 2003
- Windows XP Pro SP3, 32 bit
- "VbaUnit" and "Microsoft Visual Basic for Applications Extensibility 
5.3" enabled through Visual Basic Editor => Tools => References
- "Trust access to Visual Basic Project" checked under Excel => Tools => 
Security => Trusted Publishers

Please provide any additional information below.
If there are no valid test modules then UBound(fixtures) causes a 
subscript out of range error. 

This works for me:

Swap "For i = 0 To UBound(fixtures)"
With "For i = 0 To Main.SafeUbound(fixtures)"

Where "Main.SafeUBound" is a function used in other classes (e.g., 
TestManager) in this project.

As an alternative, this also works for me:

    If IsArray(fixtures) Then '<< extra line
        For i = 0 To UBound(fixtures)
            If (ShouldRunFixture(fixtures(i), fixtureNameToBeRun)) Then
                testCaseCount = testCaseCount + UBound(fixtures
(i).TestProcedures) + 1
            End If
        Next i
    End If '<< extra line

Original issue reported on code.google.com by [email protected] on 21 Nov 2009 at 10:10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.