Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Eclipse/Testing"
(→Running tests from within Eclipse) |
(→UI tests) |
||
(34 intermediate revisions by 16 users not shown) | |||
Line 9: | Line 9: | ||
Correctness tests can be run from within the Eclipse IDE using a "JUnit Plug-in Test" launch configuration: | Correctness tests can be run from within the Eclipse IDE using a "JUnit Plug-in Test" launch configuration: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
#In the Package Explorer, select the test or test suite you want to run. Each test package typically contains a TestSuite class that contains all the tests in that package. Suites from multiple packages are then aggregated into higher level suites. Here are some useful suites to know about: | #In the Package Explorer, select the test or test suite you want to run. Each test package typically contains a TestSuite class that contains all the tests in that package. Suites from multiple packages are then aggregated into higher level suites. Here are some useful suites to know about: | ||
#*org.eclipse.ui.tests.UiTestSuite - runs all UI tests | #*org.eclipse.ui.tests.UiTestSuite - runs all UI tests | ||
Line 28: | Line 20: | ||
#Click Run. | #Click Run. | ||
− | === | + | === Running with Tycho === |
− | + | Since adoption of Tycho, [https://bugs.eclipse.org/bugs/show_bug.cgi?id=416904 some tests have been enabled] as part of the integration-test step of the Tycho build, relying on the [https://eclipse.org/tycho/sitedocs/tycho-surefire/tycho-surefire-plugin/test-mojo.html tycho-surefire-plugin]. Those tests are run automatically when launching <tt>mvn clean verify</tt> command on the whole platform code, or <tt>mvn clean verify -Pbuild-individual-bundles</tt> if you're building a subset of Platform. They can be skipped appending <tt>-DskipTests</tt> to the command-line. | |
− | + | === Getting the required bundles === | |
− | + | Check out the test plugin containing the tests you want to run, along with any prerequisite plug-ins. Here are some plug-ins you will likely need: | |
+ | |||
+ | *org.junit - The JUnit test framework | ||
+ | *org.eclipse.test - The basic infrastructure for running Eclipse tests | ||
+ | *org.eclipse.core.tests.harness - Various utility pieces used by many tests | ||
+ | *org.eclipse.core.tests.runtime - Tests for the runtime component | ||
+ | *org.eclipse.core.tests.resources - Tests for the resources component | ||
+ | *org.eclipse.ui.tests.harness - Various utility pieces used by UI tests | ||
+ | *org.eclipse.ui.tests - Tests for the Eclipse UI | ||
=== Support for JUnit4 === | === Support for JUnit4 === | ||
Line 43: | Line 43: | ||
In some Java 7 implementations, the order of methods returned by java.lang.Class#getDeclaredMethods() is not consistent across runs. This method is used by JUnit to discover test methods, which means test order may change across executions. Generally each test method should be coded to not depend on test execution order, which also makes it easier for people to run individual tests when debugging and get consistent results. In some rare cases separate tests rely on each other, in which case you can use the test suite to hard-code a test execution order. There is also a convenience class [http://git.eclipse.org/c/platform/eclipse.platform.releng.git/tree/bundles/org.eclipse.test.performance/src/org/eclipse/test/OrderedTestSuite.java OrderedTestSuite.java] that you can use or copy for this purpose. | In some Java 7 implementations, the order of methods returned by java.lang.Class#getDeclaredMethods() is not consistent across runs. This method is used by JUnit to discover test methods, which means test order may change across executions. Generally each test method should be coded to not depend on test execution order, which also makes it easier for people to run individual tests when debugging and get consistent results. In some rare cases separate tests rely on each other, in which case you can use the test suite to hard-code a test execution order. There is also a convenience class [http://git.eclipse.org/c/platform/eclipse.platform.releng.git/tree/bundles/org.eclipse.test.performance/src/org/eclipse/test/OrderedTestSuite.java OrderedTestSuite.java] that you can use or copy for this purpose. | ||
+ | |||
+ | == Code coverage == | ||
+ | |||
+ | Platform uses [http://eclemma.org/jacoco/ JaCoCo] as code-coverage tool. JaCoCo doesn't require additional configuration than setting up a Java agent, and doesn't require to modify any class file on the filesystem. There's a Maven plugin to enable it, which works perfectly with tycho-surefire. | ||
+ | |||
+ | === Generate JaCoCo coverage data with Maven/Tycho === | ||
+ | |||
+ | Parent pom for Platform defines a <tt>coverage</tt> profile that enables and configures the [http://eclemma.org/jacoco/trunk/doc/maven.html jacoco-maven-plugin] for tests. So you can simply run <tt>mvn clean verify -Pjacoco ...</tt> and you'll get the jacoco.exec report file in the <tt>tests/target</tt> folder (or just <tt>target/</tt> if there is no <tt>tests</tt> module). | ||
+ | |||
+ | The location where this .exec file is generated can be overriden by command line settings: <tt>-Djacoco.destFile=/some/better/path</tt>. As the coverage data gets appended to the output file, you should usually make sure that there is no such file already before running tests to ensure it's only going to contain data from your current build, not a previous one. Concretely, that means that you should delete the jacoco file before running any build. | ||
+ | |||
+ | === CI builds with JaCoCo and SonarQube === | ||
+ | |||
+ | A bunch of module builds are configured to report code quality hints to [[Sonar|SonarQube]], they are visible at https://hudson.eclipse.org/platform/view/SonarQube/ . For each of these jobs, a SonarQube dashboard is created. You can see it by clicking on the <tt>SonarQube</tt> link. Then, among other, you'll be able to browse the coverage data in the Web UI of SonarQube. | ||
+ | |||
+ | Example - Platfrom resources: | ||
+ | * Job: https://hudson.eclipse.org/platform/job/eclipse.platform.resources-SonarQube/ | ||
+ | * Coverage report file: https://hudson.eclipse.org/platform/job/eclipse.platform.resources-SonarQube/lastSuccessfulBuild/artifact/jacoco.exec | ||
+ | * SonarQube (linked from Job page): https://dev.eclipse.org/sonar/dashboard/index/33441 . Coverage reports are on the right column, classes that have 100% coverage do not appear in drill-down details. | ||
+ | |||
+ | === Importing a coverage session in the Eclipse IDE with EclEmma === | ||
+ | |||
+ | {{warning|This approach is currently not working, see [[https://bugs.eclipse.org/bugs/show_bug.cgi?id=388956#c39 bug]] for details}} | ||
+ | |||
+ | [http://eclemma.org/installation.html EclEmma] provides a very good integration of JaCoCo reports into the Eclipse IDE, with metrics view, browsable coverage and highlighting lines according to whether they were covered or not. You can either let EclEmma run your tests from your IDE and it will enable coverage for this test, or reuse a previous <tt>jacoco.exec</tt> to analyze it in the IDE. This <tt>jacoco.exec</tt> can be one you generated locally by running tests with coverage enabled, or one that is archived in the [https://hudson.eclipse.org/platform/view/SonarQube/ SonarQube job of your choice] containing data from the last execution of that job. Once you've chosen a jacoco.exec, simply Use <tt>File > Import...</tt> in the IDE, and import it as <tt>Coverage session</tt>. EclEmma will guide you to enjoy coverage. | ||
+ | |||
+ | === Taking advantage of coverage === | ||
+ | |||
+ | There are several ways of taking advantage of coverage. Here is one which seems relevant for Eclipse development: rather than focusing on the coverage metrics, coverage can be used to detect '''not covered code''' and decide on '''what tests to add'''. This uses coverage as a way to identify which critical pieces of code seem to be missing test coverage. If those are pretty critical, difficult, error-prone, frequently changes... that are not covered, it most likely means that in order to provide efficient error detection for the project, some effort could be spent on writing a test that verify this critical part to avoid regressions later. Gor example, if you're about to make some refactoring, it's interesting to check whether the code you're about to change is covered, in order to detect potential issues with your change, and if the code isn't covered then it's worth considering the addition of a test as a "preparation" of your refactoring. | ||
+ | |||
+ | Focusing on the percentage may be wrong: indeed, in Java and UI development, it's pretty frequent that some code is boilerplate, or even is never meant to be invoked in realistic scenarios. Things such as Exception handling are sometimes pure defensive programming and there is not much profit in making extra-effort to cover those lines. | ||
== Session tests == | == Session tests == | ||
Line 50: | Line 81: | ||
== Performance tests == | == Performance tests == | ||
− | See the [ | + | See the [[Performance/Automated Tests|Performance Tests How-to]] |
=== Profiling performance tests === | === Profiling performance tests === | ||
Line 72: | Line 103: | ||
This instructs the [[Session Tests]] framework to specify the provided vm arguments on each nested invocation that runs the session test. Note the session test framework override mechanism requires escaping '=' characters with '==', separating multiple arguments with a ';' character rather than a space, and omitting the leading '-' character. | This instructs the [[Session Tests]] framework to specify the provided vm arguments on each nested invocation that runs the session test. Note the session test framework override mechanism requires escaping '=' characters with '==', separating multiple arguments with a ';' character rather than a space, and omitting the leading '-' character. | ||
− | The above options will instruct the profile agent to start CPU sampling immediately on startup, and to save a performance snapshot on exit. YourKit supports various [http://www.yourkit.com/docs/75/help/getting_started/running_with_profiler/additional_agent_options.jsp other options] for configuring the headless profile agent. | + | The above options will instruct the profile agent to start CPU sampling immediately on startup, and to save a performance snapshot on exit. YourKit supports various [http://www.yourkit.com/docs/75/help/getting_started/running_with_profiler/additional_agent_options.jsp other options] for configuring the headless profile agent. |
== API tests == | == API tests == | ||
Line 82: | Line 113: | ||
The table below gathers pros and cons of tools making UI testing easier. It should help developers to choose the most appropriate tool. | The table below gathers pros and cons of tools making UI testing easier. It should help developers to choose the most appropriate tool. | ||
− | {| | + | {| {{BMTableStyle}} |
|+ UI testing tools | |+ UI testing tools | ||
− | |- | + | |- {{BMTHStyle}} |
! Tool | ! Tool | ||
! License | ! License | ||
Line 92: | Line 123: | ||
! Remarks/Comments | ! Remarks/Comments | ||
|- | |- | ||
− | ! [ | + | ! [https://developers.google.com/java-dev-tools/wintester/html/index Window Tester] |
| | | | ||
− | [ | + | [https://github.com/google/windowtester Open Source] |
| | | | ||
Line 114: | Line 145: | ||
| <br> | | <br> | ||
|- | |- | ||
− | ! [ | + | ! [https://www.eclipse.org/rcptt/ RCPTT] |
| | | | ||
− | Commercial, free license available for Open Source projects | + | * Free Open Source IDE and Runner |
+ | * [http://www.xored.com/products/rcptt/rcptt-professional-support/ Commercial support] | ||
+ | |||
+ | | | ||
+ | Yes | ||
+ | |||
+ | | | ||
+ | * Designed specially to test Eclipse-based apps - plugins | ||
+ | * Supports SWT/JFace, Platform, IDE, GEF, and GMF | ||
+ | * Contexts for AUT state modeling | ||
+ | * Let you to run any subset of your tests in any order | ||
+ | * Realtime Eclipse code instrumentation and Runtime Intelligence | ||
+ | * Modern Eclipse-based IDE | ||
+ | * BDD-style scripting language ([https://www.eclipse.org/rcptt/documentation/userguide/ecl/ Eclipse Command Language]) | ||
+ | * Maven/Tycho plugin, Ant/CLI tool, and RCPTT Server to distribute test runs in the Cloud | ||
+ | * Works on OSX 64, Linux 32/64, Window 32/64 | ||
+ | * Eclipse 3.5-4.5 and upcoming releases. | ||
+ | | | ||
+ | |||
+ | | | ||
+ | * Part of Eclipse Foundation. | ||
+ | |- | ||
+ | ! [https://www.qfs.de QF-Test] | ||
+ | | | ||
+ | Commercial, free license available for Open Source projects and academic purposes | ||
| | | | ||
Line 122: | Line 177: | ||
| | | | ||
− | *very robust test automation based on "soft" events at Windows/Gtk level | + | *very robust test automation based on "soft" events at Windows/Gtk level |
+ | *more flexible and easier component recognition with the new concept of SmartIDs | ||
+ | *connection to the robot framework for keyword based tests | ||
*support for native dialogs like FileDialog | *support for native dialogs like FileDialog | ||
*excellent component recognition, including automatic naming for Eclipse/RCP components | *excellent component recognition, including automatic naming for Eclipse/RCP components | ||
*supports testing combined SWT/Swing applications | *supports testing combined SWT/Swing applications | ||
*tests are batch and thus ant-runnable producing a detailed run-log and XML and HTML reports | *tests are batch and thus ant-runnable producing a detailed run-log and XML and HTML reports | ||
− | *Jython | + | *Jython,Groovy and JavaScript scripting available |
− | *comprehensive [ | + | *Android applications can be tested on real devices and with the Emulator from Android Studio |
+ | *PDF Testing as core feature (in every developer license included) | ||
+ | *comprehensive [https://www.qfs.de/en/qf-test-manual.html] and [https://www.qfs.de/en/qf-test-tutorial.html tutorial] available online; mailing list with [https://www.qfs.de/en/qf-test-mailing-list-archive-current.html searchable archive], [https://www.qfs.de/en/blog.html blog] | ||
+ | *[https://www.qfs.de/en/support/videos.html Videos] (for beginners and advanced users) | ||
*very responsive support | *very responsive support | ||
| | | | ||
*Eclipse/SWT support limited to Windows and Linux, both x86 and x86_64, Solaris Gtk support available but no Mac | *Eclipse/SWT support limited to Windows and Linux, both x86 and x86_64, Solaris Gtk support available but no Mac | ||
− | *QF-Test is Java application but not integrated into Eclipse<br> | + | *QF-Test is a Java application but not integrated into Eclipse<br> |
*tests don't compile to JUnit | *tests don't compile to JUnit | ||
| | | | ||
+ | *Developers can integrate QF-Test in their launch configuration. | ||
*replaces the org.eclipse.swt plugin (corresponding patches are available, could be applied automatically as part of daily builds)<br> | *replaces the org.eclipse.swt plugin (corresponding patches are available, could be applied automatically as part of daily builds)<br> | ||
− | *also supports GEF/GMF | + | *also supports GEF/GMF |
− | *also supports web testing | + | *also supports [https://www.qfs.de/en/product/qf-test/web-testing.html web testing] (including AJAX-toolkits like Angular, Vue.js, GWT, Vaadin etc. & HTML5), Electron |
+ | *also supports [https://www.qfs.de/en/product/qf-test/java-testing.html Java] Swing, JavaFX and SWT testing | ||
+ | *also supports [https://www.qfs.de/en/product/qf-test/windows-testing.html native Windows testing] (Win32, .Net based on WPF or Windows Forms, Windows Apps/UWP using XAML controls, modern C++ apps (Qt) | ||
+ | *Jenkins Plugin | ||
|- | |- | ||
! [http://www.eclipse.org/jubula/ Jubula] | ! [http://www.eclipse.org/jubula/ Jubula] | ||
| | | | ||
− | Open Source | + | Open Source, EPL |
| | | | ||
Line 150: | Line 214: | ||
| | | | ||
− | *Supports Swing, SWT/RCP/GEF | + | *Supports Swing, SWT/RCP/GEF, JavaFX, HTML and iOS applications |
*Works on Windows, Unix/Linux and Mac | *Works on Windows, Unix/Linux and Mac | ||
*Black-box testing - no source code needed to execute tests | *Black-box testing - no source code needed to execute tests | ||
− | *Robust, high level test automation without any coding effort | + | *Robust, high level test automation without any coding effort |
*Incorporates best practices of software development into tests | *Incorporates best practices of software development into tests | ||
*Suitable for agile processes because tests can be written before an app is available | *Suitable for agile processes because tests can be written before an app is available | ||
− | *Robust object recognition heuristic | + | *Robust object recognition heuristic |
*Tests can be run from command line for continuous integration | *Tests can be run from command line for continuous integration | ||
+ | *Since 2015 there is also a programmatic API for writing tests using Java to be executed via e.g. JUnit | ||
+ | *Extensible to add support for own components / actions | ||
| | | | ||
Line 164: | Line 230: | ||
*not extendable without knowledge about RCP-Programming | *not extendable without knowledge about RCP-Programming | ||
*few elements missing, like loops and if-conditions | *few elements missing, like loops and if-conditions | ||
+ | *Tests are written into XML format at back-end. | ||
− | | | + | | Eclipse Project |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 200: | Line 250: | ||
| | | | ||
− | + | *long responses on important bugs e.g. [https://bugs.eclipse.org/bugs/show_bug.cgi?id=271132 271132] | |
− | *long responses on important bugs e.g. | + | |
*cannot test native dialogs (File Dialogs, Color Dialogs, etc) see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=164192 164192] | *cannot test native dialogs (File Dialogs, Color Dialogs, etc) see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=164192 164192] | ||
Line 253: | Line 302: | ||
| | | | ||
− | Yes | + | Yes, free trial available |
| | | | ||
− | *lots of nice features | + | *lots of nice features |
− | *tests SWT, Swing, Web, and | + | *fully cross-platform |
− | *scripts in various scripting languages (JavaScript, Python, Perl or Tcl) | + | *tests RCP, SWT, Swing, JavaFx, Web, Qt, Android, iOS, native Windows, native macOS and more |
+ | *full access to all Java APIs via introspection | ||
+ | *powerful object recognition mechanism | ||
+ | *scripts in various scripting languages (JavaScript, Python, Perl, Ruby or Tcl) | ||
+ | *powerful Eclipse-based IDE | ||
+ | *fully integrated BDD (Behavior Driven Development) support 100% compatible to Cucumber | ||
*support for native dialogs | *support for native dialogs | ||
*good documentation | *good documentation | ||
*responsive technical support | *responsive technical support | ||
− | *Eclipse | + | *Eclipse, Jenkins, Ant integration just to mention a few |
− | + | *Pricing starts at 2400 EUR per named user (see [https://www.froglogic.com/squish/pricing/ Pricing] for some examples | |
− | + | ||
− | + | ||
− | * | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
| | | | ||
− | |||
| <br> | | <br> |
Latest revision as of 02:29, 8 May 2022
The Eclipse Platform is tested during every build by an extensive suite of automated tests. These tests are written using the JUnit test framework. This page contains links to information about how to run and create automated tests for the platform.
Contents
Correctness tests
The majority of automated tests are testing for program correctness. A test failure on these tests implies that program behaviour is not as expected by the tests.
Running tests from within Eclipse
Correctness tests can be run from within the Eclipse IDE using a "JUnit Plug-in Test" launch configuration:
- In the Package Explorer, select the test or test suite you want to run. Each test package typically contains a TestSuite class that contains all the tests in that package. Suites from multiple packages are then aggregated into higher level suites. Here are some useful suites to know about:
- org.eclipse.ui.tests.UiTestSuite - runs all UI tests
- org.eclipse.core.tests.runtime.AutomatedTests - runs all runtime tests
- org.eclipse.core.tests.resources.AutomatedTests - runs all resource tests
- Select Run > Run...
- Choose the "JUnit Plug-in Test" category, and click the button to create a new test
- On the "Main" tab, select the appropriate application for that test. Here are some important applications to know about:
- [No Application] - Headless Mode - for running headless core (runtime, osgi, resource) tests
- org.eclipse.ui.ide.workbench - for running UI tests
- Click Run.
Running with Tycho
Since adoption of Tycho, some tests have been enabled as part of the integration-test step of the Tycho build, relying on the tycho-surefire-plugin. Those tests are run automatically when launching mvn clean verify command on the whole platform code, or mvn clean verify -Pbuild-individual-bundles if you're building a subset of Platform. They can be skipped appending -DskipTests to the command-line.
Getting the required bundles
Check out the test plugin containing the tests you want to run, along with any prerequisite plug-ins. Here are some plug-ins you will likely need:
- org.junit - The JUnit test framework
- org.eclipse.test - The basic infrastructure for running Eclipse tests
- org.eclipse.core.tests.harness - Various utility pieces used by many tests
- org.eclipse.core.tests.runtime - Tests for the runtime component
- org.eclipse.core.tests.resources - Tests for the resources component
- org.eclipse.ui.tests.harness - Various utility pieces used by UI tests
- org.eclipse.ui.tests - Tests for the Eclipse UI
Support for JUnit4
During the Helios release the platform is moving to support JUnit4 in the test framework in addition to JUnit3. For more details on this transition see Eclipse/Testing/JUnit4 Changes.
Testing on Java 7
In some Java 7 implementations, the order of methods returned by java.lang.Class#getDeclaredMethods() is not consistent across runs. This method is used by JUnit to discover test methods, which means test order may change across executions. Generally each test method should be coded to not depend on test execution order, which also makes it easier for people to run individual tests when debugging and get consistent results. In some rare cases separate tests rely on each other, in which case you can use the test suite to hard-code a test execution order. There is also a convenience class OrderedTestSuite.java that you can use or copy for this purpose.
Code coverage
Platform uses JaCoCo as code-coverage tool. JaCoCo doesn't require additional configuration than setting up a Java agent, and doesn't require to modify any class file on the filesystem. There's a Maven plugin to enable it, which works perfectly with tycho-surefire.
Generate JaCoCo coverage data with Maven/Tycho
Parent pom for Platform defines a coverage profile that enables and configures the jacoco-maven-plugin for tests. So you can simply run mvn clean verify -Pjacoco ... and you'll get the jacoco.exec report file in the tests/target folder (or just target/ if there is no tests module).
The location where this .exec file is generated can be overriden by command line settings: -Djacoco.destFile=/some/better/path. As the coverage data gets appended to the output file, you should usually make sure that there is no such file already before running tests to ensure it's only going to contain data from your current build, not a previous one. Concretely, that means that you should delete the jacoco file before running any build.
CI builds with JaCoCo and SonarQube
A bunch of module builds are configured to report code quality hints to SonarQube, they are visible at https://hudson.eclipse.org/platform/view/SonarQube/ . For each of these jobs, a SonarQube dashboard is created. You can see it by clicking on the SonarQube link. Then, among other, you'll be able to browse the coverage data in the Web UI of SonarQube.
Example - Platfrom resources:
- Job: https://hudson.eclipse.org/platform/job/eclipse.platform.resources-SonarQube/
- Coverage report file: https://hudson.eclipse.org/platform/job/eclipse.platform.resources-SonarQube/lastSuccessfulBuild/artifact/jacoco.exec
- SonarQube (linked from Job page): https://dev.eclipse.org/sonar/dashboard/index/33441 . Coverage reports are on the right column, classes that have 100% coverage do not appear in drill-down details.
Importing a coverage session in the Eclipse IDE with EclEmma
EclEmma provides a very good integration of JaCoCo reports into the Eclipse IDE, with metrics view, browsable coverage and highlighting lines according to whether they were covered or not. You can either let EclEmma run your tests from your IDE and it will enable coverage for this test, or reuse a previous jacoco.exec to analyze it in the IDE. This jacoco.exec can be one you generated locally by running tests with coverage enabled, or one that is archived in the SonarQube job of your choice containing data from the last execution of that job. Once you've chosen a jacoco.exec, simply Use File > Import... in the IDE, and import it as Coverage session. EclEmma will guide you to enjoy coverage.
Taking advantage of coverage
There are several ways of taking advantage of coverage. Here is one which seems relevant for Eclipse development: rather than focusing on the coverage metrics, coverage can be used to detect not covered code and decide on what tests to add. This uses coverage as a way to identify which critical pieces of code seem to be missing test coverage. If those are pretty critical, difficult, error-prone, frequently changes... that are not covered, it most likely means that in order to provide efficient error detection for the project, some effort could be spent on writing a test that verify this critical part to avoid regressions later. Gor example, if you're about to make some refactoring, it's interesting to check whether the code you're about to change is covered, in order to detect potential issues with your change, and if the code isn't covered then it's worth considering the addition of a test as a "preparation" of your refactoring.
Focusing on the percentage may be wrong: indeed, in Java and UI development, it's pretty frequent that some code is boilerplate, or even is never meant to be invoked in realistic scenarios. Things such as Exception handling are sometimes pure defensive programming and there is not much profit in making extra-effort to cover those lines.
Session tests
Session Tests in Eclipse are tests that require that a new Eclipse session be launched for every test case run. Thus, they have additional requirements regarding controling the environment test cases are run (VM, set of plug-ins available, configuration, instance location, command line parameters) and how results are communicated back to the test runner.
Performance tests
See the Performance Tests How-to
Profiling performance tests
It can be very useful to capture profiling data for performance tests, to help track down where the time is going. To ensure you are profiling exactly the same code paths that are running in the automated performance tests, you can attach a headless profiler to the performance tests within the test suite. Here are steps to attach a headless YourKit agent to a performance test. The resulting snapshots can later be opened for analysis from the YourKit client:
- Download the tests for the build you are interested in (available from same download page as the build itself).
- Unzip the test framework, and follow the instructions in the readme.html to configure your tests
- Create a properties file (let's say profile.properties) with the following contents:
extraVMargs=-agentlib:yjpagent=sampling,onexit=snapshot
- Invoke the performance test and specify the properties file location:
runtests "-Dtest.target=performance" -properties profile.properties <yourtarget>
If your performance test is a session test, a more complex spell is needed in your profile.properties file:
extraVMargs=-Dsetup.override.vmArgs=agentlib:yjpagent==sampling,onexit==snapshot
This instructs the Session Tests framework to specify the provided vm arguments on each nested invocation that runs the session test. Note the session test framework override mechanism requires escaping '=' characters with '==', separating multiple arguments with a ';' character rather than a space, and omitting the leading '-' character.
The above options will instruct the profile agent to start CPU sampling immediately on startup, and to save a performance snapshot on exit. YourKit supports various other options for configuring the headless profile agent.
API tests
The Eclipse project also runs an suite of API tests during builds. These tests capture problems such as breaking API changes, and correct evolution of bundle version numbers. For more details on these tests, refer to PDE/API_Tools.
UI tests
The table below gathers pros and cons of tools making UI testing easier. It should help developers to choose the most appropriate tool.
Tool | License | Recorder | Pros | Cons | Remarks/Comments |
---|---|---|---|---|---|
Window Tester |
Yes |
|
|
| |
RCPTT |
|
Yes |
|
| |
QF-Test |
Commercial, free license available for Open Source projects and academic purposes |
Yes |
|
|
|
Jubula |
Open Source, EPL |
Tests specified by drag & drop without need to record. |
|
|
Eclipse Project |
SWT Bot |
EPL |
|
| ||
Automated GUI Recorder |
EPL |
Yes |
|
|
|
TestComplete |
Commercial |
Yes |
|
|
|
Squish |
Commercial |
Yes, free trial available |
|
|
The table is in progress. Feel free to update it, if you know useful features or serious limitations of the mentioned tools. You are also welcome to add new tools.
More we know about those tools, easier to choose the best one.
Notes on what you should be evaluating on
- CI support -- ability to run tests from command line/ant
- Cross platform support -- developers use a variety of platforms -- windows, linux, mac
- Scripting capabilities -- vendor script/Java/jruby ?
- Reporting capabilities -- html/xml/push to database ?
Back to Eclipse Project home