Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#95 closed task (fixed)

write JUnit tests for TRT implementation in calculators

Reported by: Kevin Milner Owned by: Kevin Milner
Priority: major Milestone: OpenSHA 1.1
Component: sha Version:
Keywords: Cc: Ned Field


the new TRT logic and calculator parameters need to be formally tested as it gets a little complicated.

Change History (6)

comment:1 Changed 13 years ago by Kevin Milner

Status: newassigned

comment:2 Changed 13 years ago by Kevin Milner

Resolution: fixed
Status: assignedclosed

Implemented in [7269]. Coverage looks good, and covers all branches of the TRT logic tree. See trunk/test/org/opensha/sha/calc/

comment:3 Changed 13 years ago by Kevin Milner

Ned wanted a description of the tests, so here we go (also added as JavaDocs? in the test)!:

All of the tests use a fake ERF, which contains a single source. That source has a single rupture, where the tectonic region is set to the given rupture. This testing with a single rupture allows me to verify that the TRT parameter is being set correctly in the IMR (with the help of parameter change listeners). There is also a fake IMR which takes a list of supported TRT's in its constructor.

  • testHCSetBySourceFalse
    • This simply tests the case where the TRT isn't supposed to be set by the source, but rather the IMR's parameter is maintained. It sets the setTRTinIMR_FromSourceParam to false, then does calculations with ERFs of all sorts of TRTs. With each calculation, it verifies that the TRT parameter is never changed.
  • testHCSetBySourceTrueSupported
    • This tests the case where the TRT param should be set by the source, and that TRT is supported by the IMR.
    • It verifies that the TRT param is being set to the source's TRT (via listeners), and that the TRT param is set back to the original value at the end of the calculation.
  • These test the case where the TRT param is to be set by the source, but the source's TRT is unsupported by the IMR.
    • testHCSetBySourceUnsupportedAsDefault
      • This tests when the nonSupportedTRT_OptionsParam is set to use the default value
      • it does calculations with multiple unsupported TRT's, and verifies via listeners that the value used for calculation is always the default value for the TRT param
    • testHCSetBySourceUnsupportedUseOrig
      • same as testHCSetBySourceUnsupportedAsDefault, except it tests that the original value of the IMR's TRT param is used for calculation when nonSupportedTRT_OptionsParam is set as such.
    • testHCSetBySourceUnsupportedThrow
      • this tests when nonSupportedTRT_OptionsParam is set to throw an exception on unsupported TRT's
      • it simply checks that an exception is thrown in the unsupported case, and is not thrown when it's supported.

comment:4 Changed 13 years ago by Ned Field

Kevin, is the documentation in the calculator specific about how things are handled (I haven't changed anything). We should document this before we forget what we decided!

comment:5 Changed 13 years ago by Kevin Milner

Good point! I'll do that now.

comment:6 Changed 13 years ago by Kevin Milner

OK updated documentation in [7285]. Also, I removed javadocs from the actual hazard curve calc class, keeping them only in the interface, and added @Override annotations. We shouldn't duplicate the documentation in both places.

Note: See TracTickets for help on using tickets.