[Gambas-user] Using test interface for scripter testing

Brian G brian at westwoodsvcs.com
Tue Jun 23 00:00:19 CEST 2020

Will all of the test modules be included in the production application distribution when I do a make executable or make installation package?

I am including a sample app with test module for things I will need to do my testing. As you suggested I am capturing printed output, which works, but also seems to print into the test result file. 

Is there some better way to use test to test functions which produce printed messages.

Thank You
Brian G

----- Original Message -----
From: "Brian" <brian at westwoodsvcs.com>
To: "Gambas mailing list" <user at lists.gambas-basic.org>
Sent: Monday, June 22, 2020 1:58:24 PM
Subject: Re: [Gambas-user] Using test interface for scripter testing

When I press F4 I am getting the error

assert.ok is incorrectly overridden in class 'Assert'

Thank You
Brian G

----- Original Message -----
From: "Tobias Boege" <taboege at gmail.com>
To: "Gambas mailing list" <user at lists.gambas-basic.org>
Sent: Monday, June 22, 2020 1:44:39 PM
Subject: Re: [Gambas-user] Using test interface for scripter testing

On Mon, 22 Jun 2020, Brian G wrote:
> I have a few question regarding, how to test for output from an application, IE the printed output
> for example if my command line is gbs3 -v and it print 3.14.5
> how do I capture the output and compare in the test class
> I see how to test functions and class function within an application. 
> can i do an exec and capture output in the test module then compare?

There is no dedicated assertion for running an external program and
comparing its output. You would have to do it in steps:

  Dim sOut As String
  Exec ["gbs3", "-v"] To sOut
  Test.Equals(sOut, "3.14.5", "scripter version is 3.14.5")

> can i compare the content of an output file with an expected output using fileload... within the test module
> What is allowed?

A test module is mostly a normal Gambas module. The only difference
is that the execution of its methods is orchestrated and wrapped by
gb.test. You can do everything you would normally do in Gambas --
although for somewhat technical reasons you should avoid anything
that prints to stdout. (If you must, use Test.Note).

The test methods (subroutines in your test module) run any kind of
Gambas code and occasionally call methods of the Test class to make
assertions about the current state of the process. The test results
you communicate via assertions are redirected to a side channel
(actually, the main channel, stdout, which is why you should not
print to it by yourself).

Of course you can File.Load and Exec. You can even set up databases,
download files from the web or show a GUI form in your test methods.
It's normal startup class-style code that makes use of the Test class
to report test results. The parts of Gambas you can use is not
restricted by gb.test.


"There's an old saying: Don't change anything... ever!" -- Mr. Monk

----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testpackagebuild-0.0.1.tar.gz
Type: application/x-compressed-tar
Size: 12627 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200622/8c12d202/attachment.bin>

More information about the User mailing list