# Creating partial tests

## About partial tests

Normally, selecting <img src="/files/TRs4tlE0pn7ElgpeOMWT" alt="" data-size="line"> or `Write Tests` will create *complete* tests for a method. A complete test consists of Arrange, Act, and Assert sections and passes when executed. However, sometimes Diffblue Cover is not (yet) able to write complete tests and will give the reason for not producing complete tests in the Diffblue Cover tool window. In these cases, Diffblue Cover will create *partial* tests - these tests may be incomplete in various aspects:

* The test does not have assertions.
* The test does not always pass when executed.
* The Arrange or Act sections produce an error when executed.
* The test may execute code that is potentially harmful to your system, leaks resources or times out.

Creating such tests is useful to developers for two reasons:

* Firstly, it will save developers time. Instead of writing tests from scratch, they'll be able to use the partial tests as a starting point.
* Secondly, it may help developers understand why Diffblue Cover was not able to *complete* the test automatically, especially in cases where the reason for not producing a test is lack of testability.

For example, for the method `increment` in the following class:

```java
public class MyClass {
    private int x;
    public void increment() {
	  ++x;
    }
}
```

Diffblue Cover will create a *partial* test:

```java
  @Test
  public void testIncrement() {
    // TODO: This test is incomplete.
    //   Reason: R002 Missing observers.
    //   Diffblue Cover was unable to create an assertion.
    //   Add getters for the following fields or make them package-private:
    //     MyClass.x

    // Arrange
    MyClass m = new MyClass();

    // Act
   m.increment();
  }
```

The problem is clearly that Diffblue Cover has no opportunity to assert on the side effect of the `increment` method on field `x`, which is marked `private`. The developer could add a getter to `MyClass`:

```java
public class MyClass {
    private int x;
    public void increment() {
	  ++x;
    }
	public int getX() {
	  return x;
	}
}
```

Selecting <img src="/files/TRs4tlE0pn7ElgpeOMWT" alt="" data-size="line">or `Write Tests` again would now create a complete test.

## Disabling the creation of partial tests

This feature is enabled by default. To disable the creation of partial tests, go to `Diffblue > Change Settings > Partial Test Creation` and uncheck the boxes for the relevant `Allow writing tests ...` options. This will disable the creation of partial tests unless no other tests could be created. If no other tests could be created when selecting <img src="/files/TRs4tlE0pn7ElgpeOMWT" alt="" data-size="line"> or `Write Tests` then Diffblue Cover will create a [skeleton test](/features/cover-plugin/writing-tests/skeleton-tests.md) with simple inputs to get you started.

<div align="left"><figure><img src="/files/5YjF9AabNA6P9vWnX3yH" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cover-docs-preview.diffblue.com/features/cover-plugin/writing-tests/partial-tests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
