********************************************************************************
*                                                                              *
*                                   F I T  D E C O R A T O R                   *
*                                                                              *
********************************************************************************

Why do we need decorators for fit?

Consider you have a simple fit test as follows:
eg.Division
numeratordenominatorquotient()
1025
12.634.2
100425

Now you want to measure how much time this test is taking to execute. But you don't want to or cannot modify the existing test fixture. Basically you want to decorate the existing fit tests with extra features. It would be cool if you could write a decorator around your fit test which starts a timer before the execution of the fit test starts, runs the fit test as usual and once the execution is completed it records the amount of time it took to run the fit fixture. An assertion on the execution time to make sure it executes within a max time is also quite handy to be aware of the application's performance over a period of time. Something like this:

1. Max Time Decorator
fit.decorator.performance.MaxTime100
actual 0.0
milliseconds
eg.Division
numeratordenominatorquotient()
1025
12.634.2
100425

You could have other needs like, executing the same fit test multiple times or checking the standard deviation on the time it takes to execute the same test multiple times. All these seem like nice candidates for a decorator pattern. Hence this project. We have a few other interesting examples for you:

2. Max Time with Looping: You might want to loop 5 times and make sure each time it test does not take more than 100 milliseconds
fit.decorator.Loop5times
fit.decorator.performance.MaxTime100
actual 0.0
actual 0.0
actual 0.0
actual 15.0
actual 0.0
milliseconds
eg.Division
numeratordenominatorquotient()
1025
12.634.2
100425
3. Multiple Max Time with Looping: You might want to loop 5 times and make sure each time it test does not take more than 20 milliseconds and 5 times put together it does not take more than 25 milliseconds. You can clearly see there, that you can pipe the fitdecorator. They are like UNIX shell commands.
fit.decorator.performance.MaxTime25
actual 16.0
milliseconds
fit.decorator.Loop5times
fit.decorator.performance.MaxTime20
actual 0.0
actual 0.0
actual 16.0
actual 0.0
actual 0.0
milliseconds
eg.Division
numeratordenominatorquotient()
1025
12.634.2
100425
4. Time Range: You might want to check the test executes between a time range
fit.decorator.performance.TimeRange0
actual 15.0
milliseconds min and max30
actual 15.0
milliseconds
eg.Division
numeratordenominatorquotient()
1025
12.634.2
100425
5. Standard Deviation of Elapsed Time:
fit.decorator.performance.StandardDeviationOfElapsedTime0.1
actual 0.0
with average1
actual 0.0
millisecond when repeated5times
eg.Division
numeratordenominatorquotient()
1025
12.634.2
100425
6. Increment values of the column in the table at runtime: Before:
fit.decorator.IncrementColumnsValuenumeratorof typeintby5
eg.Division
numeratordenominatorquotient()
1025
1035
1045
After:
fit.decorator.IncrementColumnsValuenumeratorof typeintby5
eg.Division
numeratordenominatorquotient()
1025
1535
2045
7. Copy and append last row: Before:
fit.decorator.CopyAndAppendLastRow5number of times
eg.Division
numeratordenominatorquotient()
1025
12.634.2
100425
After:
fit.decorator.CopyAndAppendLastRow5number of times
eg.Division
numeratordenominatorquotient()
1025
12.634.2
100425
100425
100425
100425
100425
100425
8. Copy & Append last row and also increment the column values: Very useful when dealing with databases, where you want to load the same record x number of times, but coz of primary key you might want to increment the primary key column by certain value. Before:
fit.decorator.CopyAndAppendLastRow5times
fit.decorator.IncrementColumnsValuenumeratorof typeintby5
fit.decorator.IncrementColumnsValuedenominatorof typeintby1
eg.Division
numeratordenominatorquotient()
515
After:
fit.decorator.CopyAndAppendLastRow100times
fit.decorator.IncrementColumnsValuenumeratorof typeintby5
fit.decorator.IncrementColumnsValuedenominatorof typeintby1
eg.Division
numeratordenominatorquotient()
515
1025
1535
2045
2555
3065

Download FitDecorator

You can download the latest version of FitDecorator from FitDecorator @ SourceForge