blob: 11596cc9ded223aa3a0ea7a107a8def1806f1b80 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevRunningTestsPlatformApp
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevRunningTestsPlatformApp
:description: Apache NetBeans wiki DevRunningTestsPlatformApp
:toc: left
:toc-title:
:syntax: true
=== Running Tests on a Platform Application
The following article describes some of the ways you can run tests (whether unit or functional) on a NetBeans Platform application.
===== What is a unit test versus a functional test?
_Unit test_ is a test on a method not on the overall functionality of a tool or application. Example of unit test if testing of a method than should return always positive integer. _Functional test_ is testing the overall encryption algorithm that uses that method.
==== From the NetBeans IDE
* You can run a single test from the IDE by right-clicking the test's node within the project explorer and choosing 'Test' from the context menu. If you have the test source file (or the class which corresponds to the test case) open in the editor, you can run it by pressing Ctrl+F6 or its equivalent for your operating system.
* You can run all tests within a single module by right-clicking the module in the project explorer and choosing 'Test' from the context menu. The default shortcut for this on Windows and most Unix systems is Alt+F6.
* You can run all tests for the entire application by right-clicking the suite node in the project explorer and choosing 'Test All' from the context menu.
==== From the Command Line Using Ant
* You can run a single unit test by by typing `ant test-unit -Dtest.class=com.tomwheeler.example.MyTestClass` in the module's directory (where `com.tomwheeler.example.MyTestClass` is the name of the unit test class you want to execute). You can add additional JVM arguments by specifying them in the `test.run.args` system property, but be sure to quote them as appropriate for your operating system.
* You can run a single functional (GUI) test from the command line by typing `ant test-qa-functional -Dtest.class=com.tomwheeler.example.MyTestClass` in the module's directory. As with unit tests, you can specify additional JVM arguments using the `test.run.args` system property.
* You can run all unit tests for a module by running the `ant test` command from the module's directory.
* You can run all unit tests for the entire suite by running the `ant test` command from the suite directory.
==== Unit Test Code Coverage
The NetBeans Platform has inherently supported unit test code coverage (using Cobertura) since version 6.7. To generate a report which measures unit test code coverage for a single module, type `ant display-coverage-report` from that module's directory. Likewise, you can generate a report which measures unit test code coverage for all unit tests in the entire suite by typing `ant display-coverage-report` from the suite's directory. See also link:CodeCoverage.asciidoc[Code Coverage].
==== Debugging Unit Tests From the Command Line
Debugging tests from using the NetBeans IDE should be pretty straightforward, but if you want to debug a unit test from the command line (i.e. because you want to attach the debugger in a different IDE), then you simply need to run the test from the command line as described above but specify `-Dtest.run.args="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"`. The test will compile and start to run, but will pause execution until you attach the debugger on port 5005.
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevRunningTestsPlatformApp[http://wiki.netbeans.org/DevRunningTestsPlatformApp] ,
that was last modified by NetBeans user Skygo
on 2013-12-17T22:19:35Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.