Skip to content

How‐to: Run tests with AccUnit‐Loader (Access add‐in)

Josef Pötzl edited this page Mar 26, 2024 · 9 revisions

After the AccUnit Factory module with AccUnitLoader (Access add-in) has been inserted into the application under test, different variants can be used to start the tests by calling TestSuite inside immediate window or VBA code.

Run all tests

  • TestSuite.AddFromVBProject.Run

AccUnit searches in VBProject of current application for classes, which were marked with 'AccUnit:TestClass as test class. In these classes all public methods are executed as test (exception: Setup and Teardown methods).

Run all tests of a single test class

  • TestSuite.Add(new MyTestClass).Run
  • TestSuite.AddByClassName("MyTestClass").Run In both variants, all tests (public methods) of the respective test class (TestFixture) are executed.

Run selected tests only

Filter by test name

  • TestSuite.<Any Add Methode>.SelectTests(<Method name filter>).Run

    Examples

    • TestSuite.AddByClassName("SqlToolsTests").SelectTests("DateToSqlText_*").Run

      All tests of the SqlToolsTests test class whose name starts with DateToSqlText_ are executed.

    • TestSuite.AddFromVBProject.SelectTests("*UseText*,*UseValues*").Run

    • TestSuite.AddFromVBProject.SelectTests(Array("*UseText*","*UseValues*")).Run

      All tests in all existing test classes that contain UseText or UseValues will be executed.

Filter by tag

  • TestSuite.<Any Add Methode>.Filter(<FilterTags>).Run

    Tag configuration in code

    • for the test class (TestFixture): 'AccUnit:TestClass:Tags("Tag name", "Tag2")
    • for a test: 'AccUnit:Tags("Tag name")
    • for a row test line: 'AccUnit:Row(<parameters>).Tags("Tag name", "Tag2", "Tag3")

    Examples

    • TestSuite.AddByClassName("SqlToolsTests").Filter("Null as argument").Run

      All tests from SqlToolsTests that have "Null as argument" set as tag will be executed.

    • TestSuite.AddByClassName("SqlToolsTests").Filter("Tag1,Tag2").Run

    • TestSuite.AddByClassName("SqlToolsTests").Filter(Array("Tag1", "Tag2")).Run

      Tests containing Tag1 and Tag2 are executed.

CI/VCS support

Start automated test run with AutomatedTestRun / AutomatedTestRunVCS

  • Function AutomatedTestRun
    • Call via Application.Run: ReturnValue = Application.Run("{insert Add-in folder path here}\AccUnitLoader.AutomatedTestRun")
    • Returns True if all tests success (or ignored)
    • Returns Falls if one or more tests failed
  • Function AutomatedTestRunVCS (optimizes for msaccess-vcs add-in) (Video)
    • Call via Application.Run: ReturnValue = Application.Run("{insert Add-in folder path here}\AccUnitLoader.AutomatedTestRunVCS")
    • Returns a string like "Success: 5 tests passed" or "Success: 1 of 5 tests ignored"
    • Returns a string like "Failed: 3 of 45 tests failed"
    • Output test results into VCS log file
Clone this wiki locally