Update on Test Runner

Since the initial introduction of the new test runner in the NetBeans Ruby IDE it has gone through some changes and improvements that I thought I should document somewhere. Eventually I'll turn this into a wiki page. I'll explain here a bit what it does under the hoods; it might not be that interesting for all users as it should just work, but I'm sure many users like to understand what exactly it runs.

Test actions in the project context menu

There are at most three test related actions in the menu: Test, RSpec Test and AutoTest:

What actions are displayed depends on what gems you have installed; if the target platform of the project has the RSpec gem installed, the RSpec Test action is visible. Similarly for AutoTest, just that it requires the ZenTest gem.

By default, the Test and RSpec Test actions try to invoke the corresponding Rake task and run that. So if your project has a 'test' Rake task, that will be run by the Test action. For RSpec Test action the respective Rake task is 'spec'. So in effect these actions are just shortcuts for rake 'test' and 'spec' tasks, if the project has such tasks. If not, they will run all tests found in the test folders of the project; the RSpec Test actions runs all \*spec.rb files in those folders and the Test action in turn all \*test.rb and test\*.rb files.

The AutoTest action basically just runs the autotest command on the project. It was integrated with the new test runner just recently, in 6.5 Beta AutoTest results are displayed just in the output window.

Rake tasks

By default the test runner is associated with the following tasks:
  • Test/Unit: 'test' and all tasks starting with 'test:'
  • RSpec: 'spec'
I haven't found a (feasible) way to load our hooks to Rake tasks without knowing the task names that run tests, so we need to have the task names specified somewhere. To allow users to run test tasks that don't follow these naming conventions, the test runner checks for the [your project dir]/nbproject/project.properties (and/or [your project dir]/nbproject/private/private.properties -- where you should define these properties depends on whether you want to check that configuration into a VCS repo or not, typically (and by default) project.properties is shared and private.properties is not) file where you can specify 'custom' tasks. I'm copying here what I wrote to issue 141199:

The test runner now checks for project.properties (and/or private.properties) for the following properties:

  • 'test.tasks' for test/unit tests
  • 'spec.tasks' for rspec tests

If those properties are not defined, the test runner will run by default the following tasks:

  • 'test' and all tasks starting with 'test:' for test/unit
  • 'spec' for rspec
So to define additional tasks for the test runner, put something like the following either to project.properties or private.properties:
test.tasks=test,my_tests,yet_another_test_task
spec.tasks=spec,my_test_specs
If you define the property but leave the value empty, no tasks will be associated with the test runner. So if you for some reason don't want to run any tasks through the test runner, you can do:
test.tasks=
spec.tasks=

Comments:

Post a Comment:
Comments are closed for this entry.
About

emononen's blog

Search

Top Tags
Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today