NUnit Tests with COBOL .NET
After adding experimental support for using .NET classes and attributes in COBOL source code, and some playing around with System.Reflection, I was able to get the Wildcat COBOL Compiler to compile a program that contains an NUnit test, and run it from NUnit's command line utility.
More information about running NUnit tests for COBOL programs, including example source code and GUI screenshots, is available here.
I had to add a couple of new things to the COBOL syntax, but kept them in line with what Fujitsu have already done in their NETCOBOL implementation for .NET.
Here is the program I wrote - you can see the simple NUnit test at the end:
000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID. FRAMEWORK-TEST.
000030 AUTHOR. SANDY DUNLOP.
000040*Testing .NET COBOL Extensions
000050
000060 ENVIRONMENT DIVISION.
000070 CONFIGURATION SECTION.
000080 ATTRIBUTES "TestFixture".
000090 REPOSITORY.
000100 CLASS SYS-STRING AS "System.String"
000125 CLASS SYS-CONSOLE AS "System.Console"
000136 CLASS NUNIT-ASSERT AS "NUnit.Framework.Assert"
000140 DATA DIVISION.
000150 WORKING-STORAGE SECTION.
000160 77 NET-STRING OBJECT REFERENCE SYS-STRING.
000170
000180 PROCEDURE DIVISION.
000190 MAIN-PARAGRAPH.
000200 MOVE "Test Prog" TO NET-STRING
000210 INVOKE SYS-CONSOLE "WriteLine"
000220 USING BY VALUE NET-STRING
000210 STOP RUN.
000230 TEST-PARAGRAPH WITH ATTRIBUTES "Test".
000240 MOVE "teststring" TO NET-STRING
000250 INVOKE NUNIT-ASSERT "AreEqual"
000260 USING BY VALUE "teststring"
000270 USING BY VALUE NET-STRING
000280 END PROGRAM FRAMEWORK-TEST.
I plan on writing some NUnit tests for the compiler now, and making it all available online over the coming week.























