Tests

Creating Accomplishment Tests

This section is only relevant, if you are contributing a global accomplishment (such as an accomplishment in the ubuntu-community-accomplishments set) that requires any identification values, such as an e-mail address, from the user.

If this is the case, we will ask you for a test file when you submit your accomplishment for inclusion. The file is very simple to create, yet it fits into our test automation system to ensure things are working well. By using the values given in the test file, automatic testing can be made to make sure that the script gives the expected results.

Let's imagine that we are creating a test for an accomplishment called my-test-accomplishment. To verify this accomplishment, we need the users e-mail address, so we are asking of the user to provide this information through the Accomplishment Viewer. When testing though we don't have a user providing this information, so we will get it from the test file.

We create a new file in the 'tests' directory in the accomplishments collection (e.g. ubuntu-community-accomplishments/tests) with the same name as the accomplishment (e.g. my-test-accomplishment) and add the following:

[success]
launchpad-email = user@launchpad.com

[failure]
launchpad-email = fail@fail.com

The purpose of the test file is to provide validation values (e.g. such as these email addresses) that can be used to test the accomplishment for success and for failure. The values provided have to correspond to the values required in the field 'needs-information' in the .accomplishment file. The value give below the line [success] has to be a value for which the accomplishment will always be fulfilled. Likewise, the value below the line [failure] has to always fail. You can make up some unlikely, but legal, value for this field.

Using the above example, our accomplishment would have a line in the accomplishment file saying "needs-information: launchpad-email". As such, some value for this parameter has to be provided each time the accomplishment is run. In the test file we specify an email address that should complete the accomplishment (exit code 0) (this is in the success section), and an email address that should fail the accomplishment (exit code 1) (this is in the failure section). If the exit codes are as expected when given the e-mail address in the test file, the accomplishment passes the test.

When you submit your merge proposal to contribute your global accomplishment, please be sure to include the test with appropriate test values. Your global accomplishment won't be included unless there is a test. In the next section you will see, how you can verify yourself that your test file gives the expected results.

Accomplishments/Creating/Guide/Tests (last edited 2012-12-20 16:11:16 by zilvador)