MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Unit testing using imported data

On 1/11/12 4:22 PM, Adam Berry wrote:
> On 1/11/12 3:22 AM, David wrote:
>> On Jan 10, 5:00 am, David<dbco... at>   wrote:
>>> I want to setup a unit test for functions I have made. The functions
>>> perform computation on imported data. The data are HDF files. How can I setup the unit test so that the data gets imported for use in a unit test? The imported data is the input for the function.
>> I should add that I want to use the built in .mt file in Wolfram
>> Workbench. The Mathematica front end is not used. The help content in
>> Workbench doesn't have any information on importing when using the .mt
>> test files.
> For these purposes you can consider that the mt file is executed
> sequentially, and you are not just limited to Test[...] expressions
> inside of it, so basically you would do something like;
> data = Import[...]
> Test[
> 	myFunction[data]
> 	,
> 	output
> 	,
> 	TestID ->  "foo"
> ]
For some reason, the rest of my response was cut off, here is the code 
and the remainder as I sent it.

data = Import[...]

     TestID -> "foo"


You can have several tests that use the same data, just think like its a 
running kernel session (because it is). In standard unit testing 
nomenclature this is setup (the import) and teardown (the Clear).

The Clear is an important point, as if you ultimately had several files 
part of the same test run, such as with a test suite, you would want to 
ensure that no definitions incorrectly changed tests later in the run, 
following the general "if you create it you should destroy it" principle.

Adam Berry
Wolfram Workbench Development Team
Wolfram Research, Inc

  • Prev by Date: Re: Using Mathematica to create slides
  • Next by Date: This is nuts: Block[{u = 1}, g3[u]] and Block[{u = 0}, g3[u]] executes but NIntegrate[g3[u], {u, 0, Infinity}] doesn't execute
  • Previous by thread: Re: Unit testing using imported data
  • Next by thread: Re: Unit testing using imported data