-
Notifications
You must be signed in to change notification settings - Fork 22
Configuring the plugin
#Overview The fitnesse plugin needs the following information in order to successfully execute tests:
- Location of your suites and test pages
- Location of your library dependencies (jar files)
- Location of your compiled output
- Working Directory (if needed)
If you properly configure the plugin, you will be able to run tests in both run and debug mode right from the IDE, saving significant time in your test-debug cycle when building fixtures.
#Sample Project Layout I have a sample project with a single module in it:
The test suites are located in a folder called "FitnesseTests", and there is one simple fixture called "HelloWorldFixture" in the package "test.fixtures". We will setup the plugin to run the "TestHelloWorld" page from the IDE.
#Where to find the settings The configuration UI for the Fitnesse plugin is found in the Run configurations, as shown below:
The run configuration dialog will contain an item in the Defaults tree to configure the Fitnesse plugin:
#Location of test pages The plugin will need to know the name of the folder that contains suites and tests in your project. In our case the folder is named "FitnesseTests". Put the name of this folder in the "Fitnesse Root Directory" field:
This folder does NOT need to contain the entire fitnesse structure. When you run fitnesse-standalone as you normally do, it creates the "FitNesseRoot" directory. The Fitnesse plugin comes with a copy of this default folder structure. So all your project needs to have are the tests unique to your project. The "FrontPage" structure and all of the other default pages do not have to be in your project.
#Location of your library dependencies The plugin finds your dependencies from the module settings in IDEA. The "Use Classpath of Module" dropdown list provides a place for you to select the module. If you have more than one module in your project, no worries: the Fitnesse plugin will create multiple configurations and you can change the configuration for each suite or folder of tests that you like.
Any libraries listed here as either Compile, or as Test, will be added to the classpath when the plugin runs:
I use ant to build my project, and I built the ant file by hand. This means that my module definition does not include any artifacts. The ant file builds the artifacts, and IntelliJ has no knowledge of the artifact.
To make the plugin aware of my output, I added the result of the compile as a module dependency, and set the type as "Test", using the same dialog as above.
This setting is important if your tests make use of any additional files in your project. My tests often contain relative paths to data files. In order for the tests to find those relative paths, you'll need to change this directory to the root directory of your project:
To run a test or suite, you select the folder in your source tree, right-click the folder and select "Run MyTestSuite1.TestHelloWorld" or "Debug MyTestSuite1.TestHelloWorld".
When you run the test, it will create a new configuration in the run configurations, and you can edit them from the run configuration dialog:
When the test runs, it outputs the results in a pseudo-html view, like below. Tests that error will be highlighted in red, just as in the browser view of Fitnesse, and passing tests in green.
- Wiki Page Name - This setting can be left blank. When you run a suite or test, the plugin will create a new configuration and will fill this field in for you. It will contain the name of the test or suite you selected, the same way it appears in the URL when you run tests from the browser.
- VM Options - Any commandline options you would provide to Java go here. In one of my projects, I needed to load a DLL file, so I put -Djava.library.path=./lib in this field so that the JRE could find the path to the DLL file. You can use a full path or a relative path, but relative paths will be relative to the Working Directory you set earlier.
- Program Arguments - These are options that are sent to fitnesse-standalone. I've not had occassion to use these, but you can. Go here for a list of commanline options for the fitnesse-standalone test runner.
- Environment Variables - The best way I've found to provide configuration options to tests is via environment variables. Using these, I can point my test fixtures to different test servers and so on. You can set environment variables here, and because the plugin creates a separate test profile for each suite or test you run, you can provide different variables to different suites.