[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unit tests
Re: Unit tests
Mon, 4 Mar 2019 21:25:54 -0500
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.5.1
On 2/18/19 1:53 AM, Pavel Hofman wrote:
I don't think this is possible, because test code is executed in a
global context; but local functions (which is what I think you're
referring to here by "internal functions") are only visible from the
context of other functions in that file; that is, in a stack frame
workspace that is executing one of those functions.
Thanks for the very useful unit test feature of octave.
Is it possible to test an internal function of a script? E.g. the main
function (named after the script) does something complex which is hard
to test (storing/loading file) and the actual features to test are
implemented in internal functions within the script. I have not found
I way to run the internal function in the %!test section.
The way I get around this is by sticking my "for internal use"
implementation functions in a +myproject/+internal namespace. That way
you can reference them from a global context (including test code), but
it's clear that they're not part of the project's public API. And to
avoid cluttering up that namespace with a bunch of .m files, I'll often
make them static methods on a class in a single classdef .m file.
Is it possible to run all tests within a directory/subdirectories, IOW
testing the whole project? I have tried:
I think you want runtests() instead of test() here. test() tests a
single function or class; runtests() runs a suite of tests from one or
more directories. There's also __run_test_suite__, which will execute
Octave's own internal tests.
- Re: Unit tests,
Andrew Janke <=