Using ActiveRecord to Abstract “Greatest N Per Group” Queries

Some database-related projects require access to information based around maximum and minimum values. Recently, I was trying to figure out the best way to perform a “greatest N per group” query in an ActiveRecord model with a SQL database backend. Eventually, I settled on the SQL proposed by Bill Karwin on StackOverflow. Once I had […]

Incidental Code Coverage: TDD as a Solution

Some of my previous work experience involved the validation and verification (testing) of aerospace software. One of the rules for this testing was that test cases needed to structurally cover a large portion of the software under test, but this coverage was not allowed to be incidental code coverage. Incidental coverage occurs when a test case causes execution of specific lines but does not validate the inputs and outputs affected by those lines. Code coverage is usually used to determine which portions of a project are currently tested, but incidental coverage is a false positive. It causes the coverage tool to tell us that lines are tested when they may not be. For example, 100% of our code may be executed by our test suite, but some of the code may be a routine without its own set of tests covering a variety of inputs.