Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7704 > unrolled thread
| Started by | David <dbcomps@gmail.com> |
|---|---|
| First post | 2012-01-10 11:00 +0000 |
| Last post | 2012-01-12 09:17 +0000 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Unit testing using imported data David <dbcomps@gmail.com> - 2012-01-10 11:00 +0000
Re: Unit testing using imported data David <dbcomps@gmail.com> - 2012-01-11 09:25 +0000
Re: Unit testing using imported data A Retey <awnl@gmx-topmail.de> - 2012-01-12 09:21 +0000
Re: Unit testing using imported data Adam Berry <adamb@wolfram.com> - 2012-01-11 22:24 +0000
Re: Unit testing using imported data Adam Berry <adamb@wolfram.com> - 2012-01-12 09:17 +0000
| From | David <dbcomps@gmail.com> |
|---|---|
| Date | 2012-01-10 11:00 +0000 |
| Subject | Unit testing using imported data |
| Message-ID | <jeh5op$r66$1@smc.vnet.net> |
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.
[toc] | [next] | [standalone]
| From | David <dbcomps@gmail.com> |
|---|---|
| Date | 2012-01-11 09:25 +0000 |
| Message-ID | <jejki2$b9t$1@smc.vnet.net> |
| In reply to | #7704 |
On Jan 10, 5:00 am, David <dbco...@gmail.com> 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.
[toc] | [prev] | [next] | [standalone]
| From | A Retey <awnl@gmx-topmail.de> |
|---|---|
| Date | 2012-01-12 09:21 +0000 |
| Message-ID | <jem8mg$1bl$1@smc.vnet.net> |
| In reply to | #7724 |
Hi, >> 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. AFAIK you can use any kind of code within a Unit test file. Typically you will do some initialization like loading packages before the actual Test[]s. I don't see why you would have problems to import your data there or even within a Test-Definition. Are you encountering problems when doing so? > 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. If you start the tests from Workbench there is by default no FrontEnd started and at least some of the functionality needs it, although I'm not sure whether the HDF Import will need it. But if that is your problem you probably only need to wrap the Import with an UseFrontEnd to get things running. I think you probably will need to provide more details if you want to get more specific suggestions... hth, albert
[toc] | [prev] | [next] | [standalone]
| From | Adam Berry <adamb@wolfram.com> |
|---|---|
| Date | 2012-01-11 22:24 +0000 |
| Message-ID | <jel27e$ln6$1@smc.vnet.net> |
| In reply to | #7704 |
On 1/11/12 3:22 AM, David wrote: > On Jan 10, 5:00 am, David<dbco...@gmail.com> 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" ] . . . Clear[data] So 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
[toc] | [prev] | [next] | [standalone]
| From | Adam Berry <adamb@wolfram.com> |
|---|---|
| Date | 2012-01-12 09:17 +0000 |
| Message-ID | <jem8fp$17u$1@smc.vnet.net> |
| In reply to | #7704 |
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...@gmail.com> 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[...]
Test[
myFunction[data]
,
output
,
TestID -> "foo"
]
Clear[data]
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web