---
title: Charmhub | Deploy Harness Extensions using Charmhub - The Open Operator Collection
description: Deploy the latest version of Harness Extensions on any cloud.
url: https://charmhub.io/harness-extensions/libraries/declarative_tester_charm
---

# Harness Extensions

[Pietro Pasotti](https://charmhub.io/publisher/ppasotti "View all packages from Pietro Pasotti")

* [Pietro Pasotti](https://charmhub.io/publisher/ppasotti "View all packages from Pietro Pasotti")

Platform:

20.04

beta 3

```
juju deploy harness-extensions --channel beta
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/harness-extensions/libraries/declarative_tester_charm#drawer)

## charms.harness\_extensions.v0.declarative\_tester\_charm

* [*Docstrings*Docstrings](https://charmhub.io/harness-extensions/libraries/declarative_tester_charm)
  [*Code*Source code](https://charmhub.io/harness-extensions/libraries/declarative_tester_charm/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.harness_extensions.v0.declarative_tester_charm
    ```

    [Download declarative\_tester\_charm.py](https://charmhub.io/harness-extensions/libraries/declarative_tester_charm/download)
  + *Last updated* 19 Sep 2022
  + *Revision* Library version 0.2

This is a library providing a utility for unittesting code that's meant to be used in charms.

So not charm code per se, but e.g. library code, extensions, etc...

Basic usage:

> > > from charms.harness\_extensions.v0.charm\_tester import harness\_factory
> > > def test\_lib():
> > > harness = harness\_factory()
> > > harness.begin()
> > > charm = harness.charm
> > >
> > > ```
> > > @charm.run
> > > def _initialize(self):
> > >     self.lib = CharmLib(self)
> > >
> > > @charm.listener(charm.on.my_lib_event)
> > > def _on_my_lib_event(self, event):
> > >     assert event.foo == 'bar'
> > >
> > > assert not _on_my_lib_event.called
> > > harness.do_things_to_trigger_lib_event()
> > > assert isinstance(_on_my_lib_event.called, MyExpectedEventType)
> > > ```

---

Index

* [def charm\_type\_factory(
  )](https://charmhub.io/harness-extensions/libraries/declarative_tester_charm#charm_type_factory)
* + [class InvokeEvent](https://charmhub.io/harness-extensions/libraries/declarative_tester_charm#charm_type_factory-invokeevent)
* + [class TestCharm](https://charmhub.io/harness-extensions/libraries/declarative_tester_charm#charm_type_factory-testcharm)
* [def harness\_factory(
  meta,
  actions,
  config
  )](https://charmhub.io/harness-extensions/libraries/declarative_tester_charm#harness_factory)

#### def charm\_type\_factory()

Methods

charm\_type\_factory.
InvokeEvent

charm\_type\_factory.
TestCharm

#### def harness\_factory(     meta: OptionalYAML,     actions: OptionalYAML,     config: OptionalYAML )
