nkiru-ede / MavenNetworkStudy

Other
0 stars 0 forks source link

unit test organisation #4

Open jensdietrich opened 1 month ago

jensdietrich commented 1 month ago

I just had a look at unitTest/unittest.py. This script contains tests (tests look good but perhaps expand to have a few more rows and test all columns), but it also contains a function filter_and_calculate.

I think this is the actual classification code we use, so this is the code being tested, and should be kept separate from the actual test. Perhaps a function aggregate2GA (and then a similar aggregate2G). in a separate module in a separate folder.

nkiru-ede commented 1 month ago

@jensdietrich please confirm

jensdietrich commented 1 month ago

@nkiru-ede unitTest/unittest.py still does not really test the scripts -- only the output. It calls process_maven_data which reads the already processed data. So this merely tests that it can read these data.

Write tests as follows:

  1. aggregation happens in scripts aggregate2GA (aggregate2G) or similar (dataanalysis.py is not a good name as this is too general, write a simple testable script for each script).
  2. then write a test for this with a similar name, say test_aggregate2GA (test_aggregate2G, respectively)
  3. the test takes test data instead of "real" data as input (say test/data/GAV.zip), calls aggregate2GA (aggregate2G) and then tests against the output of those scripts
nkiru-ede commented 1 month ago

@jensdietrich this is now fixed. please review.

jensdietrich commented 1 month ago

@nkiru-ede I just had a look at test_aggregate_g.py -- two issues:

  1. test data are imported using an absolute path on your computer, this won't work for everybody else -- this needs to be a relative path pointing to a location within the project
  2. the test oracle is too superficial, this only tests the number of rows, not the actual content of the rows -- test each values (each row/column) in the (small) result of applying the function for test data
nkiru-ede commented 1 month ago

done @jensdietrich