Giter Site home page Giter Site logo

accesscodelib / accunit Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 3.0 34.07 MB

AccUnit - Test your VBA/Access code

Home Page: https://accunit.access-codelib.net/

License: GNU General Public License v3.0

VBScript 0.65% Batchfile 0.16% VBA 35.65% C# 45.59% Visual Basic 6.0 17.67% PowerShell 0.28%
ms-access unit-testing unittesting vba

accunit's Introduction

accunit's People

Contributors

josef-poetzl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

accunit's Issues

Array comparison with AreEqual leads to error 'At least one object must implement IComparable'.

Example test code: (from https://github.com/AccessCodeLib/AccessCodeLib/blob/master/_test/data/dao/DaoHandlerTests.cls)

Public Sub CreateParamDefArray_Use4ParamArrays_CheckArray()

   Dim Actual() As Variant
   Dim Expected(3, 1) As Variant
   Dim i As Long
   
   For i = 0 To 3
      Expected(i, 0) = i
      Expected(i, 1) = i * 2 + 1
   Next
   
   Actual = m_DaoHandler.GetParamDefArray(1, 3, 5, 7)
   
   Assert.AreEqual Expected, Actual

End Sub

Result:
Error: At least one object must implement IComparable.

Create VBE add-in for graphical output

Discussed in #29

Originally posted by FDominicus September 21, 2023
Yes, a gui interface in which one can see the tests and choose from wich to run, would be very appreciated.
IMHO testing should not be pain, it should be easy, fast and accessible. I don't feel the output in the console is that.

Import and export test classes

The test classes should be able to be imported and exported automatically from a specified directory.

  • Delivery of the application without test classes
  • Basis for automatic application deployment with prior test run

TestClassGenerator: Expected declaration remains in procedure body during row test creation, although declared as parameter

TestClassGenerator generates this code for Public Function Method1(ByVal x As Long) As Long:

'AccUnit:Row(x, Expected).Name = "Example row - please replace the parameter names with values)"
Public Sub Method1(ByVal x As Long, ByVal Expected As Long)
   ' Arrange
   Err.Raise vbObjectError, "Method1", "Test not implemented"
   Const Expected As Variant = "expected value"
   Dim Actual As Variant
   ' Act
   Actual = "actual value"
   ' Assert
   Assert.That Actual, Iz.EqualTo(Expected)
End Sub

The line Const Expected As Variant = "expected value" should not be there. It should only be there for tests without parameters.

Execute only specified test methods (filtering)

possible Interface:

Filter with tags:

  • TestSuite.AddByClassName("TestClassName").Filter("abc", "xyz", "123").Run
  • TestSuite.Add(new TestClass).Filter(...).Run
  • TestSuite.AddFromVBProject.Filter(...).Run

Filter method name:
Extend Add methods

  • TestSuite.AddByClassName("TestClassName", Array("MethodName1", "MethodName2")).Run
  • TestSuite.Add(new TestClass, ."*Xyz*").Run
  • TestSuite.AddFromVBProject ... ... Method filtering is rather unusual here, why would you want to run a particular method in multiple test classes?

Using VBA Enum Values in Row Tests

VBA enum values should become possible in the Row Test declaration to increase readability.

Actual:

'AccUnit:Row(1, #1/1/2023#) ' 1 = vbSunday
'AccUnit:Row(2, #1/1/2024#) ' 2 = vbMonday
Public Sub MyFirstTest(ByVal Expected As VbDayOfWeek, ByVal DateToCheck As Date)

Better:

'AccUnit:Row(vbSunday, #1/1/2023#) 
'AccUnit:Row(vbMonday, #1/1/2024#)
Public Sub MyFirstTest(ByVal Expected As VbDayOfWeek, ByVal DateToCheck As Date)

Assert method for strings

vbNullstring (VBA: StrPtr = 0) is null in C#.
Add a Assert methode to compare strings (with string parameters for actual/expected)

Possible variants (interface for VBA):

  • Assert.AreEqual Expected, Actual, "InfoText", ++ string compare parameter ++
  • Assert.StringCompare(IgnoreCase:=False, VbNullStringEqualEmptyString:=True).AreEqual Expected, Actual
  • Assert.StringCompare(Compare:= vbTextCompare).AreEqual Expected, Actual
  • Assert.StringCompare(....).That Actual, Iz.EqualTo(Expected)

Note: Maybe this is useful for other data types as well.

Can't get it running

The installation has worked up to the point in the Video where one type
TestSuite.name in the window
I loaded the database TestRunner.accdb
While trying to tun the test I just get:
Der Typ 'AccessCoddLib.common.VBIDETools.CodeModuleMember in der Assembly "AccessCodLib.VBIDETools,Version=0.9.10.0, Culture=Neutral, PublicKeyToken=null konnte nicht geladen werden

And that's it ...

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.