I'm trying to unit test vba by using a .net MS Test project as per a comment by Ray Vega on this thread: Best way to test a MS Access application?
Here is what I have so far:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Vbe.Interop;
namespace FarmTestSuite
{
[TestClass]
public class UnitTest1
{
Microsoft.Office.Interop.Access.Application oAccess = null;
Microsoft.Vbe.Interop.VBProject vbProject = null;
[TestInitialize]
public void Setup()
{
oAccess = new Microsoft.Office.Interop.Access.Application();
oAccess.OpenCurrentDatabase(@"\\MyFilePath\Farm.mdb", true);
vbProject = oAccess.VBE.VBProjects.Item(1);
}
[TestMethod]
public void TestMethod1()
{
Assert.AreEqual("clsTestClass",vbProject.VBComponents.Item("clsTestClass").Name);
}
}
}
However, now that I've got this far, I realise that my .net application has no knowledge of the clsTestClass type, so I cannot instantiate it, nor call its public methods. Is there any way of doing this?