E1853 write unit tests for menu

From Expertiza_Wiki
Revision as of 15:11, 27 October 2018 by Jfgiall2 (talk | contribs) (Fixed image formatting, oof.)
Jump to navigation Jump to search

E1853. Write Unit Tests for Menu.rb


Introduction

Team

Zhewei Hu (zhu6) (mentor)

  • Joe Giallo (jfgiall2)
  • Senthil Sankar (ssankar9)
  • Vato Maskhulia (vmaskhu)

Task and Results

For this project, our task was to achieve at least 90% code coverage on the menu.rb model. We ended up with 100% code coverage, and mutation testing on our test suite yielded . We believe this is a demonstration of the exemplary thoroughness of our test suite, and that these changes should be pulled in to the Expertiza master branch. This image shows our test suite running.

This image shows an abbreviated version of /coverage/index.html page which is generate after running rspec. It shows us achieving 100% code coverage.

This image shows our mutation score. Of 531 mutations, we killed 479 and 52 were left alive. This is a mutation coverage of 90.21%. While we will leave it to the TA to verify this claim, examination of the living mutants shows that many of the mutations replaced lines with equivalent code (fetching a variable as opposed to just accessing it, or substituting equivalent variables for one another). Similarly, killing the remainder of the mutants would require binding our tests to implementation, to ensure that particular methods get called. As such, we believe our mutation score is quite good.

The files involved in this commit are:

  • menu.rb - the model being tested. Contains the menu class and the node class.
  • menu_spec.rb - the spec file for menu. Contains all of our tests.
  • spec_helper.rb - we added a limit on how long tests can take to run, as one of the mutations which was generated had infinite runtime.

Background

Expertiza

Expertiza is an open source web application based on Ruby on Rails framework. It provides instructors with the ability to create, customize, and assign projects. It provides students with the ability to form teams and collaborate on these assignments, submit those assignments, as well as review others and be reviewed on their work.

Menus and Nodes

Menus (and their sub-component, Nodes) provide the foundation for navigation within the Expertiza platform. With the role of the user as input, they present to the user all possible options a user of their role can have from the top of each Expertiza screen. The Menu is critical for navigating Expertiza and exposing the correct functionality to the correct users.

Motivation

Testing is critical to ensuring that software is functional. A robust test suite which tests the returns of query messages and the side effects of command messages will help expedite development by quickly ensuring nothing has broken when changes occur.