# Writing Tests
I wanted the testing program to be as simple and easy to set up as possible. I knew if I had to remember all the boilerplate stuff each time then I would not want to write tests. So, all you must do is create each test like it is an internal, local sub. It must start with “TEST.”. The sub name should describe what the test is trying to prove. Some examples are:
TEST.CUSTOMER.EMAIL.IS.VALID:
TEST.PHONE.NUMBER.IS.REQUIRED:
# Example
Let’s say that I have created an external subroutine called DECREMENT.COUNTER. This sub will accept a number and subtract one from it. It also returns an array of any errors. First create a program. Let’s call it TEST.DECREMENTER.
ED NRL.BP TEST.DECREMENTER
Now insert this code to create the tests.
TEST.IT.WILL.DECREMENT.A.POSITIVE.NUMBER:
COUNTER = 5
CALL DECREMENT.COUNTER(COUNTER, ERRORS)
ASSERT.EQUALS(COUNTER, 4)
RETURN
TEST.IT.WILL.NOT.GO.BELOW.ZERO:
COUNTER = 0
CALL DECREMENT.COUNTER(COUNTER, ERRORS)
ASSERT.EQUALS(COUNTER, 0)
RETURN
TEST.A.BLANK.STRING.WILL.RETURN.ZERO:
COUNTER = ""
CALL DECREMENT.COUNTER(COUNTER, ERRORS)
ASSERT.EQUALS(COUNTER, 0)
RETURN
TEST.IT.REQUIRES.A.NUMBER:
COUNTER = "BLAH"
CALL DECREMENT.COUNTER(COUNTER, ERRORS)
ASSERT.HAS.ERROR(COUNTER:" is not a number.", ERRORS)
RETURN
And that is it. The test program should have nothing else. You do not even need to compile it. MV.TEST will scan through that program and make a new, temporary program that will iterate through each of the tests and output which ones pass and fail.
# Result
I have written a test program for a real program I am working on. To run it yourself, you would just type:
MV.TEST NRL.BP TEST.FSR.STORE
Here is the output of the test (I have purposefully made some that fail so you can see what that looks like).
