HP ALM 12.5 - How to Make Test Sets Read Only in Test Lab Module - alm

I am trying to make particular test set Read Only, meaning no one will be able to run, delete or modify these particular test set.
I also don't know how to make Test Sets and also Folders Read Only for Delete and Modify functions yet, any help there I will be thankful too):
In Test Lab module Script --> TestSet_MoveTo Sub:
If TestSet_Fields.Field("TC_Cycle_ID").Value = 103 Then
Actions.Action("TestSetView.Run").Enabled = FALSE
Actions.Action("TestSetView.RunTestSet").Enabled = FALSE
Else
Actions.Action("TestSetView.Run").Enabled = TRUE
Actions.Action("TestSetView.RunTestSet").Enabled = TRUE
End If
Now it disables "Run" button for all test sets in Test Lab in addition to Test Set with Test Set ID 103. I'm not sure if I'm doing anything wrong in coding above. This should have only disabled the Run and RunTestSet buttons for Test Set ID 103.
Also, even when test sets show disabled Run button (for all test sets), the Status of a test set can be changed through Execution Grid. How can I disable this field?

You need to use the CY_CYCLE_ID and not the TC_Cycle_ID field.
If TestSet_Fields.Field("CY_CYCLE_ID").Value = "103" then
....
End If
As you can see, the CY_CYCLE_ID field represents the testset ID:

Related

Global Variables - Katalon Studio

I am working with Cucumber & Groovy in Katalon Studio.
I have ten feature file lines in Cucumber and corresponding step definitions.
In my cucumber feature file first step has the indicator where if the first line is passed with the parameter with "NO RUN", the test case should not run and it should be moved to the next test case.
So, I thought, I will use the Global variable indicator where I can handle in the test and assign the values. I see that and could create the Global Variable (RUN INDICATOR) under the Execution profile. But, not sure how I need to use that variable in the test script or refer.
Can someone please provide the inputs on this to proceed further ?
Step Definition
#Given("running indicator flag (.*)")
def run_indicator_flag(String ind1) {
println "Passing Indicator " + ind1
assert ((ind1!='') || (ind1!='N'))
WebUI.openBrowser('', FailureHandling.STOP_ON_FAILURE)
}
You can use test listeners to do that.
Create a Global Variable with the empty string value (You need to do this before actually running the test case/suite):
GlobalVariable.RUN_INDICATOR = ''
You will update its value either manually or preceding test will update it to whatever value you wish.
Create a test listener with the following code
#BeforeTestCase
def sampleBeforeTestCase(TestCaseContext testCaseContext) {
if(GlobalVariable.RUN_INDICATOR=='NO RUN'){
testCaseContext.skipThisTestCase()
println "Test Case skipped"
}
}
If the GlobalVariable.RUN_INDICATOR is set to 'NO RUN', this test case will be skipped and the test suite will continue with the next one.

SoapUI enable list of test steps (Groovy)

I have some SoapUI test cases, where I need to enable specific test steps.
I decided to wrote a simple Groovy script which enables required test steps.
At first I disable all test steps in the test case:
//Get the names of all test steps
def oNameList = testRunner.testCase.getTestStepList().name
for(iNameCounter in (0..oNameList.size-1))
{
testRunner.testCase.getTestStepByName(oNameList[iNameCounter]).setDisabled(true)
}
Then I have list with test steps to enable:
def list = ['Login', 'Get Messages', 'Logout']
for (i = 0; i <list.size; i++) {
testRunner.testCase.getTestStepByName(list[i]).setDisabled(false)
}
It works If 'list' elements exist as test steps in that test case. But not If one of them is missing. Is it possible to make it skip missing test steps? I need to make this groovy work on every test case (in 'list' there will be all preferred test steps from every test case in test suite).
For example:
I have Test case with these test steps: 'Login', 'See bill history', 'Logout'.
I will run this groovy script which disable all test steps.
Then it starts to enable test steps specified in the 'list'.
But it fails because in that test case there doesn't exist test step 'Get messages'.
I want to make it to skip enabling test steps from 'list' which doesn't exist in the actual test case.
Output on this test case should be - enabled: 'Login', 'Logout'; disabled: 'See bill history'

Selecting endpoints dependent on which level to run tests

I have a bit of structural dilemma in soap. When running tests, it can be possible to run tests at project, test suite or test case level.
Now currently what happens is that we can run a whole project via project level and it will display a prompt box to select an endpoint (through a project level setup script and produces a project report using the project level tear down script).
However, it may be possible that the tester may not want to run a whole project and only wants to run a test suite or even a test case. Now it may be possible that the tester may only want to run only a test suite or even only a test case. Now it would be a hassle disabling suites or cases you don't want to run.
Now the problem i have is that if I start putting prompt boxes to select endpoints at suite or case level, everytime we hit a suite or case, it will always ask for an endpoint. Another thing is that I am thinking not creating suite or test case reposts because if running many suites or cases one by one, it is just an overkill on reporting.
I like your thinking on this, but I was speaking with my professional colleague and what we're thinking is this:
Add the below code for all test suites and test case level in their relevant setup scripts where it asks for endpoint (this is same code used in project set up script for selecting endpoint):
import com.eviware.soapui.support.*
def alert = com.eviware.soapui.support.UISupport
def urls = []
project.properties.each
{
if (it.value.name.startsWith("BASE_URL_"))
{
urls.push(it.value.name.replace("BASE_URL_", ""))
}
}
def urlName = alert.prompt("Please select the environment URL", "Enter URL", urls)
if (urlName)
{
def url = project.getPropertyValue("BASE_URL_" + urlName)
def urlBase = "BASE_URL_" + urlName
project.setPropertyValue("BASE_URL", url)
switch (urlBase){
case "BASE_URL_TEST":
project.setPropertyValue("DOMAIN_NAME", "TEST");
break;
case "BASE_URL_STAGE":
project.setPropertyValue("DOMAIN_NAME", "STAGE");
break;
default:
project.setPropertyValue("DOMAIN_NAME", "NO DOMAIN");
break;
}
}
else
{
log.warn 'haven\'t received user input'
log.warn 'No base URL is selected or cancelled, try again'
assert false
}
Now what we add is the following and we may need to use properties but again see what you think is best:
If test is ran at project level, it will prompt to select endpoint through project setup script but it will not ask for selecting endpoint through test suite or test case setup script. So it's only a single endpoint selection
If test is ran at suite level, it will prompt to select endpoint through project setup script but it will not ask for selecting endpoint through test case setup script. So it's only a single endpoint selection
For running at test case level, well it only runs for that test case so it's at the lowest level as it asks for an endpoint for that test case.
We can't have setup scripts disabled at any level because there maybe over code in those setup script that will need to be exectued, we just need a way to say depending on which level, don't ask for selecting endpoints at lower levels.
Seems complicated to implement but does anyone know best way to implement this or do they even have a better idea than this theory?
Thanks
For a moment, let us assume you get it done for all levels (project, suite, and each case). May be you forgot about the step level ;-)
Do you have any Pros in your approach?, for me, NO.
Cons in your approach:
Each time user executes a test (be it project / suite / any test case), engineer needs to select value from the drop down, which is unwanted though testing against the same server as previous test case & little annoying.
Test execution requires manual intervention each time test execution is invoked.
User Interface is required as drop down being used.
Will be come road block / hurdle for end to end automation or to achieve automation.
Test execution can't done in headless mode. And this is important if you need to use Continuous Integration tools.
Proposed Approach :-
If I have to do the above, I would do the following. That would be clean, damn simple, no such complications would arise that you had mentioned in the long summary.
Looks there are following project properties defined with addresses of the test servers:
BASE_URL_TEST
BASE_URL_STAGE
There is also another project property defined BASE_URL and all the above logic is to allow the user to select the value from above properties to base URL value.
Now all user have to do is change the value for project property BASE_URL. I would think just user have to set one of the below value by hand what he / she needed as (one of them) before proceeding with their tests.
${#Project#BASE_URL_TEST} or
${#Project#BASE_URL_STAGE}
NOTE that a property value can be referred into another property by the use of Property Expansion like above.
With the above, user can set whatever is needed and change only if required or have to change the test server.
No setup script at any level is required any more, and just simply change the value of the property.
Properties are given to make to life simple, which can be used in N number of places and maintain the project easily.
Most Importantly, overcome the Cons mentioned in the beginning.
It is general practice that SoapUI is used to design the tests, and SOAPUI_HOME/bin/testrunner.bat or .sh utility to execute the tests in command line mode and that is the way to achieve Continuous Integration.
That's why use of properties helps here to achieve the above without any issues.
Even simple:
Just have one project property BASE_URL (remove others), user have to just edit the property value and have the test server name / IP address and is done for once, say http://testjuniper. Isn't it dead simple?
And I believe, the engineer would definitely know which server he / she is using to execute the tests.
Having said that, now user do not have to bother at all, irrespective of executing a project / suite / test case, as long as testing is carried out against the same server / environment.
Once, the test execution is finished against TEST environment, the engineer may move on to other environment say STAGING, just change BASE_URL property value accordingly.

Adding loadTestsFromTestCase from a string

I am creating an application where I pass in one or more test cases to the TestLoader that then get run.
I can run and add the testcase to the suite like this
suite1 = unittest.TestLoader().loadTestsFromTestCase(mymodule.Testcase01)
suite = unittest.TestSuite([suite1])
However, what I actually want to do is something like this
myTestcaseAsString="mymodule.Testcase01"
suite1 = unittest.TestLoader().loadTestsFromTestCase(myTestcaseAsaString)
suite = unittest.TestSuite([suite1])
What I want to happen is that the value of myTestcaseAsaString is passed into loadTestsFromTestCase as if it was hard coded like the first example
Is that possible? (my long term goal is to be able to add multiple testcases to teh same suite - if that makes a difference)
Thanks
Grant
This is what I ended up doing
suite2 = unittest.TestLoader().loadTestsFromTestCase(eval(testcasemodule))
I have full control over the testcasemodule value
Thanks
Grant

Masking answer options in Confirmit (jscript)

I'm trying to mask the answer options that show up in a 3DGrid question item in Confirmit, using the value of a background variable.
E.g. when "background1" ==1, display answer category 1. If "background1" ==0, do not display answer category 1. If "background2" ==1, display category 3, otherwise do not. In any case, display answer category 2.
Hopefully this is easy for someone out there (I'm a psychologist, not a coder...so not so much so for me :/)
Thanks!
In order to access the data inside a question/variable we can use the f function of confirmit.
for instance:
f('my_question_id').get();
When masking a question, we need to pass in a Set object so Confirmit knows what Code's to show and not to show.
Often you will mask using a Set from a previous question. So you pass in the question_id and Confirmit does all the other magic.
Here we have the problem of not having a Set, so we will have to create our own.
For this, there are 2 approaches (can be found in the scripting manual under Working with Sets > Methods of the set Object > add and remove and Working with Sets > User defined functions...)
I'm going to stick to the first one because it is easier to use ;)
What we will do first is create a script node (it doesn't matter where you create it, just somewhere in the survey, I often have a folder Functions with all my script nodes in somewhere at the bottom of my survey)
In that script file we will have our function that crates our set:
function CreateMyAwesomeSet()
{
//create an empty Set
var mySet = new Set();
//if background1 equals 1, add 1 to our Set
if ( f('background1').get() == '1' )
{
mySet.add(1);
}
//return the Set of allowed Codes
return mySet;
}
Here we declare a function that we now can use wherever we want to.
So now, If we want to use this Set, we add a Code Mask to your grid:
CreateMyAwesomeSet()
You can ofcourse change the name of the function, and add extra if statements.
hope this helps

Resources