Tests Best Practices

Cory Johns cory.johns at canonical.com
Tue Apr 14 11:59:44 UTC 2015


That's a good point that we definitely need recommended best practices
for writing charm tests.  I am also behind using the built-in
unittest[1] library to organize and structure the tests.   I am also
behind encouraging combining tests inside test cases where possible,
with the caveat that we frame the recommendation with explicitly
calling out the tear-down behavior and explaining why it is
recommended to combine test cases, since there will be cases where
that is not the best approach because a new environment is required
(even though it will be the right thing to do most of the time).

I think we should also include a call-out to the template test
provided by `charm add tests` (or `charm create`) as the best way to
get started, as it also incorporates these practices.  However, we
should note about changing the name of the generated test case file
away from 99-autogen.

Thanks for bringing this up and offering these good suggestions.

On Thu, Apr 9, 2015 at 6:17 PM, José Antonio Rey <jose at ubuntu.com> wrote:
> Hello everyone,
> A couple days ago I was going through the docs, and found out that there are
> not best practices or recommendations for tests. Now that we are trying to
> ensure quality, I believe it would be a good idea to have them.
> I know that one of the benefits of Juju being so open is that you can write
> your charm or tests in any language. However, having these best practices
> will allow us to set a recommendation for when people are getting started,
> or don't know how to proceed. I understand that this may be seen as a
> limitation, but it is instead a guidance for when someone comes to the
> ecosystem, or wants to get some tips on how to write tests.
> I was thinking on starting with two points. These are assuming that you are
> using Python and Amulet to write your tests. The first one, the use of the
> unit_tests packages. As a starter with Python, I have found out the use of
> it quite easy, and helps me condensate everything into one big file. Which
> takes me to the second point, having everything in one file. This would
> allow us to save resources and time (since bundletester tears down for each
> file), and would make it look nicer. At least that's how I've been
> proceeding for my last tests.
> What do you think? I'm all ears to new suggestions or why these aren't good.
> --
> José Antonio Rey
> --
> Juju mailing list
> Juju at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju

More information about the Juju mailing list