tobin / Elektrotickle

Linear circuit simulation in Matlab
5 stars 1 forks source link

Create an automated testing framework #2

Open tobin opened 10 years ago

nicolassmith commented 10 years ago

You might want to look at https://github.com/Optickle/Optickle/blob/Optickle2/tests/testClasses/OptickleReferenceTest.m and https://github.com/Optickle/Optickle/blob/Optickle2/tests/testClasses/TickleTestOnOpt.m

It can compare the output of either two current installations of Optickle, or compare the current installation with some saved output created at an earlier time.

It decides what to do based on the config structure. If config.referenceType is 'Files' then config.referencePath points to a directory where the reference files are saved.

>> addpath(genpath('~/repos/Optickle'))
>> foo = TickleTestOnOpt(@optFP)       

foo = 

  TickleTestOnOpt with properties:

         optFuncHandle: @optFP
    testFunctionHandle: @()computeResults(testCase)
       referenceStruct: []
      calculatedStruct: []
             testLabel: 'TickleTestOnOpt(@optFP)'
                config: [1x1 struct]

>> foo.config.referencePath = pwd;     
>> foo.saveTestFunctionOutputToReference();
>> ls
TickleTestOnOpt(@optFP).mat  TickleTestOnOpt(@optFP).txt

>> foo.run()
Running TickleTestOnOpt
---===Optickle Test===---
Reference type is Files
Reference path is /home/nicolas/tmp/poop
Optickle path is ~/repos/Optickle
......
Done TickleTestOnOpt
__________

ans = 

  1x6 TestResult array with properties:

    Name
    Passed
    Failed
    Incomplete
    Duration

Totals:
   6 Passed, 0 Failed, 0 Incomplete.
   0.82422 seconds testing time.

>> 

Can tell you more about it if you'd like.