Quantcast
Viewing latest article 6
Browse Latest Browse All 11

Categorizing tests and generating test results

- While executing testcases we need to categorize tests on several basis, say severity, type of testing etc

- We can catagorize our tests using the Junit Categories class(http://junit.org/javadoc/4.9/org/junit/experimental/categories/Categories.html )

- Categorizing tests would help to determine the tests that we would want to execute. Categorizing on severity can help us segregate the tests(major, critical) that we would want to execute if we are going for a Smoke test.

- We could categorize tests by setting tags. Categorizing in terms of severity may include tags like major, minor etc.

- In order to generate a category, we have to create an interface for each category type. In the above case we have to create two interfaces for “Major” and “Minor”.

- For each test that we want to categorize, we have to add the tag “(‘Interface name’)”

Image may be NSFW.
Clik here to view.

- After creating the categories, we can create a TestSuite to execute the tests as per the category.

- The tests from different class files ,mentioned in the @SuiteClasses(), falling under the category specified in the TestSuite would be executed.

Image may be NSFW.
Clik here to view.

- After executing the tests, we need to generate a test results

- We can get the test result by extending the Junit TestWatcher class(http://junit-team.github.io/junit/javadoc/4.10/org/junit/rules/TestWatcher.html ) and generate html reports , graphical charts using this test result.

Image may be NSFW.
Clik here to view.

- The succeeded(), failed() and finished() functions of TestWatcher class can be overridden to get the respective method names or perform other actions on the type.

- A rule needs to be set in each test class for the TestWatcher to watch the test status.

Image may be NSFW.
Clik here to view.

- Once the test result is collected, we can generate the reports using this data to show the method details under each type with the pass/ fail status

Image may be NSFW.
Clik here to view.

Written By: - Jaya Mohanty, QA Engineer, Mindfire Solutions


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 6
Browse Latest Browse All 11

Trending Articles