LogoLogo
diffblue.comFree trial
  • Discover Diffblue Cover
  • Get Started
    • What is Diffblue Cover?
    • Get started
      • Free trial
      • Get started - Cover Plugin
      • Get started - Cover CLI
      • Get started - Cover Pipeline
      • Get started - Cover Reports
    • Specs & Reqs
    • Reference Deployments
    • Licensing
      • Online license activation
      • Offline license activation
      • Diffblue License Manager
    • Update Cover
    • FAQs
    • Diffblue Learning
      • Get started
        • Just the basics
        • Free trial
        • Cover Plugin (IDE)
        • Cover CLI (Command Line)
      • Developer
        • Unit tests (IDE)
        • Unit tests (CLI)
        • Test coverage
      • DevOps
        • GitHub
        • GitLab
        • Other CI
      • Administrator
        • Admin - IntelliJ
        • Admin - CLI
        • Admin - Reports
      • Test coverage
        • Developer
        • Senior developer
        • Cover Reports Administrator
  • EVALUATION & ONBOARDING
    • Proof of Value
    • Jumpstart
      • Prerequisites for onboarding
      • Phase 1: Up and running
        • Module 1: Create your Cover unit test baseline
        • Module 2: Cover Pipeline CI integration
      • Phase 2: Developer productivity
        • Module 3: Getting started using Cover
        • Module 4: Introduction to Cover Reports
      • Phase 3: Advanced topics
        • Module 5: Speed up your test execution
        • Module 6: Getting more from Cover
  • Features
    • Cover Plugin
      • Writing tests
        • Gutter icons
        • Menu options
        • Run configurations
        • Cover Plugin tool window
        • Test Review
        • Test examples
        • Creating partial tests
        • Creating skeleton tests
        • Covering all enum values
        • Test insertion order
        • Diffblue Sandbox
        • Environment Check Cache
      • Project configuration
        • General dependencies
        • Test framework dependencies
      • Cover Plugin settings
        • Test Naming
        • Test Formatting
        • Spring configuration options
        • Method Annotations
        • Test Directory
        • Reset Cover Plugin settings
      • Cover Plugin admin
        • Core Maintenance
        • Cover Plugin toolbar menu
        • Cover Plugin status bar widget
        • Telemetry
        • Memory management
        • Using SonarQube with Cover Plugin
        • Log files
        • Troubleshooting
    • Cover CLI
      • Writing tests
        • Command summary
        • Test examples
        • Creating partial tests
        • Customizing test inputs
        • Customizing test setup
        • Test naming
        • Test formatting
        • Test insertion order
        • Patch files
        • Diffblue Sandbox
        • Operational behaviors
        • Test validation
      • Project configuration
        • Preflight checks
        • General dependencies
        • Test framework dependencies
        • Compiling your project successfully
          • Building a Maven project
          • Building a Gradle project
        • Configuring Cover to work with your project's build system
          • Quick guide
          • Configuration file in detail
          • Getting Started with Ant Projects
          • Default configuration
        • Mocking using Mockito
        • Spring profiles
        • Runtime environment
      • Commands & Arguments
        • Environment configuration for CI
        • Packages, classes, and methods
        • Quoting command line arguments
        • Argument files
      • Cover CLI admin
        • Core Maintenance
        • Telemetry
        • Memory management
        • Using Cover CLI in Eclipse
        • Using SonarQube with Cover CLI
        • Log files
        • Troubleshooting
      • Environment Configuration
    • Cover Pipeline
      • Cover Pipeline for CI
        • Quick Start - General
        • Quick Start - Jenkins
        • Quick Start - Azure Pipelines
        • Quick Start - AWS Codebuild
        • Integrating Diffblue Cover into CI on pull requests
        • Installation - VMs or CI run
      • Cover Pipeline for GitLab
        • Introduction
        • Installation and initial setup
        • GitLab workflow
        • Configuration
        • Troubleshooting
        • Related topics
      • Cover Pipeline for GitHub
        • Introduction
        • Installation and initial setup
        • GitHub workflow
        • Configuration
        • Troubleshooting
        • Related topics
    • Cover Reports
      • Cover Reports Contributor
        • Java project config (JaCoCo)
        • Generate and upload reports bundles
        • Authenticated uploads
      • Cover Reports User
        • Navigation
        • Dashboards
        • Telemetry data
        • Export API
        • Considerations
      • Cover Reports Administrator
        • Install and update Cover Reports
        • Configuration options
        • Database backup
        • SSO with Cover Reports
        • Uninstall Cover Reports
    • Cover Optimize
      • Get started - Cover Optimize
      • Cover Optimize & Gradle
      • Cover Optimize & Maven
      • Patch files
    • Cover Refactor
      • Get started - Cover Refactor
    • Cover Annotations
      • Mocking Annotations
      • Custom Input Annotations
      • Interesting Value Annotations
    • Output Codes
      • E - Environment Codes
      • L - License Codes
      • R - Reason Codes
      • T - Testability Codes
      • V - Validation Codes
      • Working with output codes
        • Working with code E020
        • Working with codes E057 to E065
        • Working with code E085
        • Working with code R005
        • Working with code R006
        • Working with code R008
        • Working with code R011
        • Working with code R012
        • Working with code R013
        • Working with code R026
        • Working with code R031
        • Working with code V003
    • Tutorials
      • How to measure test quality
      • How to improve code coverage
      • How to test a new feature
      • How to find regressions
      • How to use Diffblue Cover in test driven development (TDD)
      • How to write tests for Kotlin projects
      • Examples of tests created by Diffblue Cover
      • Best practices for testing private methods
  • Updates & Upgrades
    • Update Cover
    • Cover Editions
    • What's new
    • Release archive
      • 2025-05-01
      • 2025-04-02
      • 2025-04-01
      • 2025-03-02
      • 2025-03-01
      • 2025-02-02
      • 2025-02-01
      • 2025-01-02
      • 2025-01-01
      • 2024-12-02
      • 2024-12-01
      • 2024-11-02
      • 2024-11-01
      • 2024-10-02
      • 2024-10-01
      • 2024-09-02
      • 2024-09-01
      • 2024-08-02
      • 2024-08-01
      • 2024-07-04
      • 2024-07-03
      • 2024-07-01
      • 2024-06-02
      • 2024-06-01
      • 2024-05-02
      • 2024-05-01
      • 2024-04-02
      • 2024-04-01
      • 2024-03-02
      • 2024-03-01
      • 2024-02-02
      • 2024-02-01
      • 2024-01-02
      • 2024-01-01
      • 2023-12-02
      • 2023-12-01
      • 2023-11-03
      • 2023-11-02
      • 2023-11-01
      • 2023-10-02
      • 2023-10-01
      • 2023-09-02
      • 2023-09-01
      • 2023-08-02
      • 2023-08-01
      • 2023-07-03
      • 2023-07-02
      • 2023-07-01
      • 2023-06-02
      • 2023-06-01
      • 2023-05-02
      • 2023-05-01
      • 2023-04-02
      • 2023-04-01
      • 2023-03-02
      • 2023-03-01
      • 2023-02-02
      • 2023-02-01
      • 2023-01-02
      • 2023-01-01
      • 2022-12-02
      • 2022-12-01
      • 2022-11-02
      • 2022-11-01
      • 2022-10-03
      • 2022-10-02
      • 2022-10-01
      • 2022-09-02
      • 2022-09-01
      • 2022-08-05
      • 2022-08-03
      • 2022-08-02
      • 2022-08-01
      • 2022-07-02
      • 2022-07-01
      • 2022-06-02
      • 2022-06-01
      • 2022-05-02
      • 2022-05-01
      • 2022-04-02
      • 2022-04-01
      • 2022-03-02
      • 2022-03-01
      • 2022-02-02
      • 2022-02-01
      • 2022-01-02
      • 2022-01-01
      • 2021-06-02
      • 2021-02-01
  • Legal
    • Diffblue Legal
      • Diffblue End User License Agreement (EULA)
      • Cover Third Party Notices and/or Licenses
      • Privacy Notice
Powered by GitBook
On this page
  • Module examples
  • Packages, classes, and methods
  • Package example
  • Class example
  • Method example
  • Multiple specification entries

Was this helpful?

Export as PDF
  1. Features
  2. Cover CLI
  3. Commands & Arguments

Packages, classes, and methods

By default, dcover create automatically runs across the entire project. If required, you can specify what modules, packages, classes, or methods you want to restrict these operations to.

Module examples

For modules this can be done in two different ways. Diffblue Cover can be run on a single module by invoking dcover in the appropriate module directory. If dcover is run across an entire multi-module project, you can also fine tune the selection of modules using the --exclude-modules=<module>,[<module>,...] option;

Example: dcover create --exclude-modules=scripts

or alternatively, you can directly specify the modules you want Diffblue Cover to run on by using the --include-modules=<module>,[<module>,...] option.

Example: dcover create --include-modules=api

Packages, classes, and methods

If required, you can specify what packages, classes, or methods you want to restrict these operations to, by specifying one or more entry points on the command line using [<entryPoint>...] .

Example: dcover create io.corebanking.Account

Also you can use similar specifications for excluding particular packages, classes, and methods from test-writing.

Example: dcover create --exclude=io.corebanking.Account


Package example

Specify a package entry point on the command line using the standard Java naming convention, plus an optional trailing dot and/or wildcards.

Syntax: dcover create <package>[.][*]


Trailing dot: dcover create <package>.

For example: dcover create com.a.

Description: Write tests for all accessible methods within package <package> (in our example, com.a) and any sub-packages. For example, tests could be written for sub-packages com.a.B and com.a.b.C . Trailing dot prefix doesn't support wildcard *.


No trailing dot: dcover create <package>

For example: dcover create com.a

Description: Write tests for all accessible methods within any package that begins with <package> (in our example, com.a) and any sub-packages. For example, tests could be written for com.apple, com.apricot, com.apricot.pip, etc.


Wildcard: dcover create '<package>*'

For example: dcover create '*.controller.*'

Description: Write tests for all accessible methods within any package that contains <package> (in our example, .controller.) and any sub-packages plus wildcard matches. For example, tests could be written for com.controller.apple, org.controller, etc. Note that when using the * wildcard character, the entry point must be enclosed in single quotes, as shown.


Class example

Specify a class entry point on the command line using the standard Java naming convention, plus an optional trailing dot and/or wildcards.

Syntax: dcover create <package>[.][*].<className>[.][*][extends][implements[|]]


Trailing dot: dcover create <package>.<className>.

For example: dcover create io.diffblue.corebanking.account.Account.

Description: Write tests for all accessible methods within class <package>.<className>. only - in our example, io.diffblue.corebanking.account.Account. Trailing dot prefix doesn't support wildcard *.


No trailing dot: dcover create <pacakge>.<className>

For example: dcover create io.diffblue.corebanking.account.Account

Description: Write tests for all accessible methods within any class that begins with <package>.<className> - in our example, this could include ...Account and ...AccountException.


Wildcard: dcover create '<package>*.<className>*'

For example: dcover create 'io.diffblue.corebanking.account.*Exception'

Description: Write tests for all accessible methods within any class that begins with <package> and contains <className> plus any wildcard matches. In our example, this could include ...UserException and ...AccountException. You can also combine this with * in the package name. Note that when using the * wildcard character, the entry point must be enclosed in single quotes, as shown.

For example: dcover create '*.User*' could match io.diffblue.account.User, io.diffblue.account.UserController, io.diffblue.order.UserController and io.diffblue.order.UserRepository.


extends: dcover create '<package>.<className> extends <package>.<parentClassName>'

For example: dcover create 'io.diffblue.account.Foo extends io.diffblue.Bar'

Description: Similar to regular Java syntax, the extends keyword instructs Cover to write tests for all accessible methods within any class where the name contains <package>.<className> and extends/is a direct child to a class where the name contains <package>.<parentClassName>. Note that when using the extends keyword, the entry point must be enclosed in single quotes, as shown.

For example: dcover create '* extends io.diffblue.Bar' could match any class in any package that extends io.diffblue.Bar.


implements: dcover create '<package>.<className> implements <package>.<interfaceName>'

For example: dcover create 'io.diffblue.account.Foo implements io.diffblue.Bar'

Description: Similar to regular Java syntax, the implements keyword instructs Cover to write tests for all accessible methods within any class where the name contains <package>.<className> and implements an interface where the name contains <package>.<interfaceName>. You can specify a list of interfaces using the | delimiter - here, a target class has to match at least one of the interfaces. Note that when using the implements keyword, the entry point must be enclosed in single quotes, as shown.

For example: dcover create '* implements *.Callable | *.Runnable' will match all classes that implement either Callable, Runnable, or both.


Method example

There are two ways of specifying particular methods to be selected for operation - Prefix and Extended.


Prefix

Specify a method entry point on the command line using the standard Java naming convention, plus an optional method descriptor. Wildcards, extends, and implements are not supported for prefixes.

Syntax: dcover create <package>.<className>.<methodName>:[<methodDescriptor>]

Example: dcover create io.diffblue.corebanking.account.Account.addToBalance:

Description: Write tests for the specified method. If the optional method descriptor is omitted, all parameter and return types will be included.

Example: Complete prefix of addToBalance(double[] sum, String account) tiwith ASM 4.0 signature will look like this 'io.diffblue.corebanking.account.Account.addToBalance:([DLjava/lang/String;)'.


Extended

The Extended syntax supports wildcards, extends, and implements, utilizing "Java-like" syntax.

Syntax: dcover create '<package>[.][*].<className>[.][*][extends][implements[|]] {<methodName>[*][([<parameterType>,...])];}'

  • dcover create 'com.example.Foo { bar(int[], double);}' will match bar method in Foo class with exactly two parameters in order int[], double.

  • dcover create 'com.example.Foo { bar();}' will match bar method in Foo class with no parameters only.

  • dcover create 'com.example.Foo { bar;}' will match bar method in Foo class with any number and types of parameters.

  • dcover create 'com.example.Foo { *bar;}' will match any method in Foo class which ends with *bar. foobar() method will match in our example. Wildcard * can match any part of a method name but can't be used in parameter type.

  • Short qualifiers can be used when parameter is a primitive byte, char, double, float, long, short, boolean or an object of type String, Object, List. For other object types full qualifier has to be specified. com.example.Foo { bar(String);} but com.example.Foo { bar(com.example.FooBar);}.

  • Constructor method has to be specified as <init>. dcover create 'com.example.Foo { <init>(int);}' will match Foo(int) constructor method of Foo class.

  • Note that when using the Extended syntax, the entry point must be enclosed in single quotes, as shown.


Multiple specification entries

In order to specify multiple Extended syntax entries the whitespace separator should be used for the create command.

Example: dcover create 'com.foo.*' 'com.bar.*'

In case --exclude option is used it has to be specified for each entry separately.

Example: dcover create --exclude='com.foo.*' --exclude='com.bar.*'

PreviousEnvironment configuration for CINextQuoting command line arguments

Last updated 7 months ago

Was this helpful?

A method descriptor is a list of type descriptors that describe the parameter types and the return type of a method, in a single string. For more information on method descriptors, see section 2.1.4 of the .

ASM 4.0 A Java bytecode engineering library