Menu

Is it possible to use SimplyVbUnit in access 2010 vba?

Help
2012-12-20
2013-01-16
  • Sylvain Mc Quade

    Does anyone know how to get SimplyVbUnit to work in Access 2010? If so, a quick tutorial would be much apprciated. For the moment I tried adding a reference to the dll but whenever I try to add the activex control to a form access crashes.

     
  • Kelly Ethridge

    Kelly Ethridge - 2012-12-20

    Hello,
    Unfortunately, SimplyVBUnit wasn't intended for use with MS Access. They definitely don't play nice when MS Access tries to directly use the control. However, I do have an experimental dll that can be referenced within Access. The dll is an external runner, hosting SimplyVBUnit in a standard VB6 form and exposes a global method (ExternalRunner.Run) that accepts a TestSuite object. I've only briefly tested in Access 2003, so I have no idea how it works in 2010.

    I've attached the dll to this message so you can try it and give some feedback. To use the dll, reference it from within the Access VB code editor and create a function in a standard module. In the module you will need to create your suite of unit tests then call the ExternalRunner.Run method.

    Public Function Tests()
      Dim Suite As New TestSuite
      Suite.Add New MyTestClass1
      Suite.Add New MyTestClass2
    
      ExternalRunner.Run Suite
    End Function
    

    You can make a macro or whatever to run this from other parts of Access.

     
    • Sylvain Mc Quade

      Thank you very much. I'll start experimenting with this right away. I'll be sure to post some feedback once I get some tests written.

       
  • Sylvain Mc Quade

    I created a blank database (.accdb). added references to framework 4.1, type library 4.0, and externalRunner.

    Class Greeter:

    Public Function sayHello() As String
    sayHello = "Hello"
    End Function
    

    Class GreeterTests:

    Public Sub sayHello_methodCalled_returnsHello()
      Dim classUnderTest As Greeter
      Set classUnderTest = New Greeter
    
      Assert.That classUnderTest.sayHello, Iz.EqualTo("Hello")
    End Sub
    

    module testrunner:

    Public Sub runtests()
      Dim tests As GreeterTests
      Dim suite As TestSuite
    
      Set tests = New GreeterTests
      Set suite = New TestSuite
    
      suite.Add tests
    
      ExternalRunner.Run suite
    End Sub
    

    When stepping through runtests() with the debugger, ExternalRunner.Run suite causes a type mismatch error.

     
    • Kelly Ethridge

      Kelly Ethridge - 2012-12-21

      Ok, remove the SimplyVBUnit.Framework.dll reference and make sure there is a reference to the SimplyVBUnit.Component.ocx instead. When you are trying to add a control to a form, the UI runner will show up as SimplyVBComp.UIRunner. You don't need to add the control to a form. Just make sure you have a reference to the SimplyVBUnit.Component.ocx.

       
  • Max Dean

    Max Dean - 2013-01-15

    Did this get sorted out? I am interested in the same thing as Sylvain, wanting to do unit testing for VBA in my MS Access 2010 projects.

     
    • Kelly Ethridge

      Kelly Ethridge - 2013-01-15

      I haven't heard back from the original poster. You are more than welcome to download the dll I included in my first post of this thread and see if that will work or not.

       
  • Christoph Juengling

    You should give http://accunit.access-codelib.net/ a try. It's an Access add-in which relys on the core functions of SimplyVBUnit 3.0 (supposedly not 4.1), but provides an interface that better fits into the MS Access GUI. I'm not that much familiar with the tool, because I have no Access project at the moment. But according to the web site (German language only) there is no restriction, so I assume it's working with all current Access versions.

     
    • Kelly Ethridge

      Kelly Ethridge - 2013-01-16

      That looks like a very nice add-in. It may be exactly what everyone is looking for!

       

Log in to post a comment.