Skip to content

Setting up test suites

Thomas Thomassen edited this page Sep 2, 2014 · 4 revisions

Setting up test suites

A test suite is a collection of automated test cases.

A minimal test can look like this:

require "testup/testcase"
class TC_HelloWorld < TestUp::TestCase
  def test_say
    hello = HelloWorld.new
    result = hello.say("World")
    assert_equal("Hello World", result)
  end
end

TestUp::TestCase build upon the MiniTest gem with additional features customized for SketchUp. Refer to MiniTest::Assertions for a list of assertions available.

File structure

A folder with .rb files represent a test suite and each file represent a test case. The folder name is the name visible in the tabs in TestUp's interface.

Each test case class must be prefixed TC_ and the .rb file containing the test case should have matching name. So for the example given above the file should be named TC_HelloWorld.rb

Each test inside each test case is a method prefixed test_. The order of execution is random so make sure tests are not relying on each other.

Manifests

It is possible to provide a list of method which you expect there to be test for. This is useful in when you want an overview of how much test coverage you have. This list is simply a file coverage.manifest located in the test suite folder which list each method on separate lines:

Array.transform
Array.transform!
Array.vector_to
Array.x
Array.x=
Array.y
Array.y=
Array.z
Array.z=
Geom.closest_points
Geom.fit_plane_to_points
Geom.intersect_line_line
Geom.intersect_line_plane
Geom.intersect_plane_plane
Geom.linear_combination
Geom.point_in_polygon_2D
Geom::BoundingBox.add
Geom::BoundingBox.center
Geom::BoundingBox.clear
Geom::BoundingBox.contains?
Geom::BoundingBox.corner
Geom::BoundingBox.depth

TestUp will then display a percentage indicator that tells you how many of the methods have tests written for them. Each missing test will be marked with a blue question mark in the interface.

Clone this wiki locally