Sandy Dunlop
A 27 year old software consultant living in Glasgow.
IRC: jaavaaguru on irc.freenode.net
Email: sandy@sorn.net
NUnit is a unit-testing framework for all .NET languages. It was initially ported from JUnit for Java and is available from www.nunit.org.
NUnit can be used from COBOL programs compiled with the Wildcat COBOL compiler in the same way as it can be used from C# or other .NET languages. In C#, you may have a program that contains a very simple test like this:
using System;
using NUnit.Framework;
namespace TestNS
{
[TestFixture]
public class TestClass
{
int Number_A;
[Test]
public void Test_A()
{
Number_A = 1;
Assert.AreEqual(1,Number_A);
}
}
}
Note the use of the TestFixture and Test attributes.
When being compiled, this would need a reference to the nunit.framework.dll assembly. With the Wildcat
COBOL compiler, this assembly reference is given in the same way as with the Microsoft C# compiler - by using
the /reference: command-line option.
The same simple test could be written in a COBOL program like this:
000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID. FRAMEWORK-TEST.
000060 ENVIRONMENT DIVISION.
000070 CONFIGURATION SECTION.
000075 ATTRIBUTES "TestFixture".
000080 REPOSITORY.
000096 CLASS NUNIT-ASSERT AS "NUnit.Framework.Assert"
000100 DATA DIVISION.
000110 WORKING-STORAGE SECTION.
000120 77 NUMBER-A PIC S(9).
000150
000160 PROCEDURE DIVISION.
000300 TEST-A WITH ATTRIBUTES "Test".
000305 MOVE 1 TO NUMBER-A
000310 INVOKE NUNIT-ASSERT "AreEqual"
000320 USING BY VALUE 1
000330 USING BY VALUE NUMBER-A
000340 END PROGRAM FRAMEWORK-TEST.
The unit tests can be run from the command line using nunit-console or from the NUnit GUI
like this:
The screenshot above shows some of the compiler's own test running.