Skip to content

How‐to: AccUnit Attributes

Josef Pötzl edited this page Oct 28, 2024 · 1 revision

AccUnit:TestClass

Marks a class as a test class.

Syntax

' AccUnit:TestClass

Can be used in

  • Declaration scope of a class

AccUnit:TestRelated

Marks a class, standard module or forms/reports as utility modules for tests. These code modules or forms/reports can be imported or exported in the same way as test classes.

Syntax

' AccUnit:TestRelated

Can be used in

  • Declaration scope of a class (also class of form, report)
  • Declaration scope of a module

AccUnit:Row

Setting the row test parameters

Syntax

' AccUnit:Row(Param1, Param2)

Can be used in

  • Declaration scope of a test procedure

Example

Method to test

Public Function GetFoo(ByVal JaNein As String) As Boolean
    GetFoo = False
    If JaNein = "Ja" Then GetFoo = True
End Function

Test method

'AccUnit:Row("Ja", True)
'AccUnit:Row("Nein", False)
Public Sub GetFoo_ValueTest(ByVal value As String, ByVal Expected As Boolean)
    Assert.That GetFoo(value), Iz.EqualTo(Expected)
End Sub

AccUnit:TestClass:Tags

Marks test classes. Can be used to filter the tests.

Syntax

' AccUnit:TestClass:Tags(Tag1, Tag2, Tag3)

Can be used in

  • Declaration scope of a test class

AccUnit:Tags

Marks test methods. Can be used to filter the tests.

Syntax

' AccUnit:Tags(Tag1, Tag2, Tag3)

Can be used in

  • Declaration scope of a test procedure

Remarks

  • Tags at method level are automatically displayed at the level of the respective test class when the test results are displayed.

AccUnit:Ignore

Do not run test class or method.

Syntax

' AccUnit:Ignore
' AccUnit:Ignore(Comment)
' AccUnit:Row(Param1, Param2).Ignore(Comment)

Can be used in

  • Declaration scope of a test class
  • Declaration scope of a test procedure
  • Extension of the Row attribute

AccUnit:ClickingMsgBox

Mouse clicks for Msgbox replacement function

Syntax

' AccUnit:ClickingMsgBox(vbYes, vbOk, vbNo)
' AccUnit:Row(Param1, Param2).ClickingMsgBox(vbYes, vbOk, vbNo))

Can be used in

  • Declaration scope of a test procedure
  • Extension of the Row attribute

AccUnit:Rollback

Creates a transaction on the standard Jet workspace (DAO) before each run of the test method and rolls this transaction back after the test method has been run.

Syntax

' AccUnit:Rollback

Can be used in

  • Declaration scope of a test procedure

Not usable for

  • Built-in domain aggregate functions (DLookup, DCount, etc.) -> use substitute functions
  • Code that uses transactions itself.
  • Server backends integrated via OleDb (SQL server & Co.)

Attention

The rollback does not reset the counter for AutoValue columns. After an insert has been rolled back, the AutoValue assigned is no longer available.