> For the complete documentation index, see [llms.txt](https://docs.shouldly.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shouldly.org/documentation/completedsuccessfully.md).

# CompletedSuccessfully

`ShouldBeCompletedSuccessfully` asserts that a `Task` has already completed successfully (`TaskStatus.RanToCompletion`). On a `Task<T>` it returns the task's result, so you can assert on it straight away.

It checks the task's status at the moment it is called and **does not wait** for the task to finish. Use it when the code under test should have completed synchronously, such as a cache hit or a stubbed dependency that returns a completed task. To wait for a task to finish, `await` it or use [`Should.CompleteIn`](https://docs.shouldly.org/documentation/completein.md).

If the task faulted, the message includes the exception that faulted it. If it was canceled, or had not yet completed, the message says so.

```cs
var lookup = Task.FromException<int>(new InvalidOperationException("Cache miss"));
var value = lookup.ShouldBeCompletedSuccessfully();
```

[<sup>snippet source</sup>](https://github.com/shouldly/shouldly/tree/master/src/DocumentationExamples/CodeExamples/ShouldBeCompletedSuccessfullyExamples.ShouldBeCompletedSuccessfully.codeSample.approved.cs#L1-L2) <sup>|</sup> [<sup>anchor</sup>](#snippet-ShouldBeCompletedSuccessfullyExamples.ShouldBeCompletedSuccessfully.codeSample.approved.cs)

**Exception**

```
lookup
    should be completed successfully but faulted with
System.InvalidOperationException: Cache miss
```
