Unit testing in Natural

Many modern languages have

Hi Curtis;

My guess (never have tried it) is that the debugger could be used to implement such a mechanism. You could replace , for example, a READ loop with a FOR loop. Then put a Breakpoint at the start of the FOR loop to generate a “data set” that normally would come from Adabas.

Upon reflection, it would seem to be more complicated than just working with the code.


I agree whole heartedly with Steve. It’s way more trouble than it’s worth and, besides, one of the beauties of the language is its simplicity in that an English major could almost read it like a novel. Apologies to all English majors but the point is that that simplicity makes many of those ‘easy’ errors easy to find.

A couple of things struck me in reading your otiginal post though. Many developers already write ‘driver’ nmodules for unit testing the sub programs that they write before integrating them into the existing code. Many shops have formal module naming standards. Combine these two and you could have a formal naming convention for your drivers and “require” - hate that word but - that your developers create and maintain them alongside the ‘real’ code. You could also require that every module have an independent variable established called let’s say +DEBUG-MORE that when determined to be TRUE causing a sub program to bypass all it’s code and just return fake data when called. You’d have to have a way to ensure that code you wanted executes was executed maybe by forcing this independent to be FALSE inside a module and then setting it TRUE again before the END statement - allowing for ESCAPE clauses. You’d have to remove these before implementing though.

Anyway these are just a few thoughts.

We have naming standards and we have drivers. There are several problems with relying on drivers:

  1. Running tests in a driver manually takes time, and it is highly likely that important test cases will be skipped or misinterpreted, even if you have a testing checklist.

  2. In a complex system, you need a lot of different drivers. Testing each one manually would again take a lot of time.

  3. In general, complex systems may have interdependencies with other systems, such that important aspects of their behavior cannot easily be tested. If module X callnat’s module Y but I have no control over Y’s data, even in the test environment, then it will be very difficult to arrange that I can test every scenario.

  4. Even where I’m performing a READ or FIND against files I control, it can be difficult to set up the file for every test, especially if other developers are sharing the same file.

Natural code is easy to read, but in my experience this does not prevent bugs. Part of the problem is that Natural has limited abstraction mechanisms, so programmers often have to write a lot of code to do things outside Natural’s sweet spot. Typically, we modularize those functions into subprograms, but they still need to be tested, and ideally we would like to run the tests whenever we make a change, which means:

  • we need to have a set of tests that have already been specified
  • they need to be fast to run (definitely not manual)
  • they need to not create conflicts with other developers

My $0.02.

duplicated post

Ruby on Rails video explaining the basic idea: http://www.patchedsoftware.com/RailsEnvy-LoveTests.mov

Here’s another one if you prefer the microsoft world: http://www.bestechvideos.com/2007/06/23/aspnet-how-do-i-practice-test-driven-development (press “View Video”).

While I agree with the presenter that it will improve your design, we have a huge need for testing tools that allow us to write tests for existing, often poorly designed, code. It’s hard to refactor it if you don’t have tests.

Hi Curtis,

I don

Hi Curtis,

I have the same problem, so I started writting by own Test-Framwork.
My Test-Framework based on the idea form Junit.
You are writting TestCases for your Modul, with asserts you compare the results.

After finishing all tests you get a list of all errors (linenumber, TestCase, errormessage like Junit) and a statistic about asserts and TestCases.

There are a lot of things to do …

If you are intressent I can send you an example.


we published the NatUnit-Testframework on Sourceforge:

Feel free to download and using it.

It is working on OpenSystem, feel free the add the Mainfraim :wink:

Best regards,

Markus Wessjohann

We released version 2.0 of NatUnit this week. It’s completely free of charge, 100% Natural, and should run on any platform now. New features include parameterized tests and test suites.

Take a look yourself:


NaturalONE provides unit testing. My understanding is NaturalONE uses the Eclipse unit testing.
I like that it allows us to save and combine unit tests.