Karen B Absent Member.
Absent Member.
2422 views

Grouping test cases in Silk4J

Jump to solution

In Silk4J I am trying to create a "test plan" by grouping tests together so I can run them consecutively, as I have test cases broken up in different classes.  I looked in the help and it talked about using the @Categories but when I try that in my scripts it tells me that "Category cannot be resolved to a type".

Are there any other examples of grouping the tests?  I am finding the Help not very helpful.

~Karen

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Contributor
Micro Focus Contributor

RE: Grouping test cases in Silk4J

Jump to solution

Hi Karen,

It is not possible to call test cases in a particular order with Silk4J, however please see the post below which describes how tests can be manipulated into being executed via sort order:-

community.microfocus.com/.../10552.aspx

Regards,

Chris

0 Likes
6 Replies
Micro Focus Expert
Micro Focus Expert

RE: Grouping test cases in Silk4J

Jump to solution

Hi Karen,

The error "Category cannot be resolved to a type" would indicate that your Test class does not import the Category class. For example:

import org.junit.experimental.categories.Category;

With regards to grouping tests, the following article on java.net describes the topic well. I have also attached an exported Silk4J 15.5 project that demonstrates how to implement categories:

The class "borland.example.ExampleTest" contains 3 test methods, 2 of which interact with our "Insurance" demo application and 1 which interacts with the "GMO" demo application. For each test method, I specify a Category which specified the application that is tested by that method, e.g.:

@Category(InsuranceAppTest.class)
@Test
public void autoQuote()


@Category(GMOTest.class)
@Test
public void gmoTransaction()


Therefore if I only want to execute the tests against the "Insurance" demo application, I create a suite that specifies that the "InsuranceAppTests" should be executed:

@RunWith(SilkTestCategories.class)
@IncludeCategory(InsuranceAppTest.class)
@SuiteClasses( { ExampleTest.class})
public class InsuranceAppSuite {

}

If I now execute "InsuranceAppSuite", only those test methods with the category "InsuranceAppTest" in the class "ExampleTest" will be executed.

Let me know if this helps.

-Robert

0 Likes
Karen B Absent Member.
Absent Member.

RE: Grouping test cases in Silk4J

Jump to solution

Thank you.  This works nice.  However is there a way a can call test cases in a particular order?  

What I am seeing with this is that it runs tests in a random order - at least that is what it looks like in the TrueLog Explorer.  Some of my tests cases have to be based on a prior one finishing.  

~Karen

0 Likes
Highlighted
Micro Focus Contributor
Micro Focus Contributor

RE: Grouping test cases in Silk4J

Jump to solution

Hi Karen,

It is not possible to call test cases in a particular order with Silk4J, however please see the post below which describes how tests can be manipulated into being executed via sort order:-

community.microfocus.com/.../10552.aspx

Regards,

Chris

0 Likes
Karen B Absent Member.
Absent Member.

RE: Grouping test cases in Silk4J

Jump to solution

That sort order works great!  Thank you very much!!

~Karen

0 Likes
cwBrendan Absent Member.
Absent Member.

RE: Grouping test cases in Silk4J

Jump to solution

It seems like your question has been answered but this entire thread begs the question of if it's a good idea to have testcases that depend on being run in a specific order. The answer to that question is that it's a bad idea. Testcases should be independent from each other and should test one thing per testcase.

0 Likes
Karen B Absent Member.
Absent Member.

RE: Grouping test cases in Silk4J

Jump to solution

You are right about having them run independently and I do agree with that.  But what I have to do is set data up in one application and then go to another application to see if it worked correctly.  So they will need to run one after another.  I have not figured out how to change URLs on the fly or how to deal with two windows open yet. But till I do I can at least have the tests running and then change it later.

~Karen

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.