kdahlquist / GRNmap

Gene Regulatory Network modeling and parameter estimation
BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

Begin unit testing framework #37

Closed dondi closed 9 years ago

dondi commented 9 years ago

Start building a test suite for GRNmap. Start by learning MATLAB's framework for it (http://www.mathworks.com/help/matlab/matlab_prog/write-simple-test-case-with-functions.html). Once you are comfortable with running the samples, start by writing tests against the actual GRNmap code. Focus on pure mathematical computations first; we will eventually branch out to things like file validation etc.

trixr4kdz commented 9 years ago

Created sub-branch

dondi commented 9 years ago

Immediate goals to be done by March 18:

trixr4kdz commented 9 years ago

Added test files to test_suite branch

trixr4kdz commented 9 years ago

(entered by @dondi typed this)

During our 3/18 meeting, we were able to write a real-world test. It has a single assert so far and only tests one file, but it is a genuine start.

Tasks under this issue from this point:

dondi commented 9 years ago

@trixr4kdz discovered the addpath function; for replicability it needs to use relative paths. Here is a reference, and also based on the file structure the path needed looks like it should be ../../../matlab:

http://www.mathworks.com/matlabcentral/answers/4701-how-to-manage-relative-addpath-uses-in-subfunctions-when-using-svn-for-example

dondi commented 9 years ago

Next task is to finalize the file structure using addpath and calltests, after which tests can now just be churned out.

dondi commented 9 years ago

After structure is finalized, work can be merged into beta and eventually into master.

trixr4kdz commented 9 years ago

Added more test cases. Fixed file paths so that we can keep test cases in test_files folder instead of matlab folder. Also, removed warning messages from test cases. Still need to make more test cases

kdahlquist commented 9 years ago

Let's discuss this at our next meeting in the context of an actual workflow for testing related to #74 and #84. I'm thinking that we might be able to get Tessa involved in working with @trixr4kdz in doing some testing tasks.

kdahlquist commented 9 years ago

Merge test-suite branch into beta branch and all further development along these lines should be in beta.

kdahlquist commented 9 years ago

In the next week, @tessaam and @trixr4kdz should work together on automating tests that @tessaam has completed manually (e.g. issue #74 and others).

kdahlquist commented 9 years ago
trixr4kdz commented 9 years ago

@dondi or @bengfitzpatrick just a quick question, even when I make tests for the individual functions, I basically still have to run the entire program so the new output will overwrite the past output that I'm trying to compare with. Also, that would mean that running all 16 tests will take very long overall. Is there a way to make running the tests faster and not overwrite the testing files or is this exactly how its supposed to be? Currently, the tests have been split up into the individual functions they are trying to test (i.e. readInputSheetTest is testing readInputSheet)

trixr4kdz commented 9 years ago

Possible solutions that @kdahlquist proposed to prevent overwriting files (that we will have to implement anyway in the future):

About running GRNmap in parallel, we need to take advantage of the multi-core computers and assign individual runs to each core. I will need to ask Grace how to do this.

dondi commented 9 years ago

From a general architecture perspective, the ideal solution is to actually intercept the data before they get written out. Unless streaming of some sort is happening, the actual results should be in memory initially, with the writing to a file being a last step. A unit test should be able to receive the data before it is written to a file. This test would verify that the computed data were indeed wat was expected.

With that separation, the actual writing to a file can then be tested by itself, in isolation from the computation. One would prepopulate the data before it is written out, then write out to a temporary file (thus avoiding the overwrite issue), and finally assert that the file content does correspond to the in-memory data.

If achieving this separation will involve too much refactoring at the moment, then the numbered-files approach may be the intermediate solution. But in the long term we should aim for this separation of data computation from data output to a file.

One last thing: many language platforms have a "generate temporary file" function. If MATLAB has this, we can use that approach for the test file naming and handling. One advantage of temporary files is that the system auto-deletes them for you when done.

kdahlquist commented 9 years ago

We will verify at the meeting today whether or not we can close this issue. It seems that we need to open separate issues dealing with @dondi 's comments:

trixr4kdz commented 9 years ago

The items listed in the comment above are now separated into different issues. See #135 and #136. Also, #134 describes using setUp and tearDown methods for more efficient test runs.

kdahlquist commented 9 years ago

Since the individual issues are now broken out, we are going to close this issue.