Cannot change value of variable in groovy soapui - variables

def activeEnvironment = "a"
activeEnviornment="b"
log.info("active environment = $activeEnvironment")
When I run the code above, on the log it shows active environemnt = a. Why doesnt it show b?

Your spelling of environment is wrong in your second assignment, so you've created a new variable
Change
activeEnviornment="b"
To
activeEnvironment="b"

Related

Using result from the first request and passing in the second request- POSTMAN

I want to use the result which is "id" and use it in the second request POST
Saving it as environmental variable in the first request(under tests)
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("id", jsonData.token);
Here is the second request looks like, not sure what I am doing wrong here
Your request is correct.
As long as you set an environment variable, you may USE this environment. From your print screen I see "no environment" on the top right corner.
I suggest either you create an environment where to save your environment variables and then use it or you use a global variable, postman.setGlobalVariable("id", ...) instead
Alex

Specifying build parameters to FAKE

I am essentially asking for an update to date answer to the already answered question: Can I pass a parameter to a F# FAKE build script?
Here is build.fsx
let revisionNumber = getBuildParamOrDefault "rev" "123"
Target "Log" (fun _ ->
trace ("Revision Number: " + revisionNumber)
)
RunTargetOrDefault "Log"
Output running Fake.exe .\build.fsx:
Perfect!
Output running Fake.exe .\build.fsx rev=456 (as suggested by this answer: https://stackoverflow.com/a/26597179/2382536):
Starts with
But at the bottom gives the correct result:
What format do I need to pass the parameters in to get rid of the warning message?
Passing parameters is done using the --envvar parameter. Until recently you can just add parameters in a way you did after the build target but not anymore. I believe this was changed in order not to confuse build parameters with (optional) build target name.
So, try this:
fake build.fsx Push --envvar rev 456
I just want to share the link to the official documentation:
TLDR:
You can either use
--envvar [-ev] <name:string> <value:string>
to set a variable to a custom value, or
--envflag [-ef] <name:string>
to set a variable to true, or
--fsiargs --debug+ buildscript.fsx someArg1 anotherArg2
to pass all arguments (including build script name, importent!) direcly to fsi.exe

How do I set project parameters?

In a package located in the SSISDB node I am trying to execute, I have one package parameter and one project parameter.
I am able to set the package parameter by providing ExecutionValueParameterSet to the execute method. It is something like this:
Dim setValueParameters As New ObjectModel.Collection(Of PackageInfo.ExecutionValueParameterSet)
Dim exp As New PackageInfo.ExecutionValueParameterSet
exp.ObjectType = 30
exp.ParameterName = sp.Name
If sp.Value IsNot Nothing Then
Select Case sp.TypeCode
Case TypeCode.String
exp.ParameterValue = sp.Value
Case Else
exp.ParameterValue = Convert.ChangeType(sp.Value, sp.TypeCode)
End Select
End If
setValueParameters.Add(exp)
package.Execute(use32BitRuntime, er, setValueParameters)
Now, this works fine for package parameters. But I cannot set parameters on the project level.
I have tried the following:
package.Parent.Parameters(sp.Name).Set(ParameterInfo.ParameterValueType.Literal, sp.Value)
However, I still get errors that the parameter is missing. If I check package.Parent.Parameters(sp.Name).ValueSet parameter after setting it is false.
Any ideas?
The problem was the ObjectType. The magic number assigned to them has meaning.
20 Project Parameter
30 Package Parameter
50 Execution Parameter
You can also get an idea of what is available by querying the integration services catalog
SELECT * FROM SSISDB.catalog.object_parameters AS OP
See also
Execute SSIS 2012 Package with Parameters via .Net
Thanks to #billinkc I found that I should set project parameters on the same ExecutionValueParameterSet but use exp.ObjectType = 20 for project parameters.
Also see this SSIS WIKI page about parameters:
http://social.technet.microsoft.com/wiki/contents/articles/21978.execute-ssis-2012-package-with-parameters-via-net.aspx

BeanShell PreProcessor updates User define variables

I'm very new at JMeter issues.
In a test script i have a BeanShell PreProcessor element that updates some variables previously defined at a "User Defined Variables" element.
Latter those variables are used in "Http Requests". However, the value that is used in the http request is the default one.
The scripts seems to be working due to some debug print();
My question is if it's necessary to delay the script to be sure that the BeanShell finishes?
Thanks a lot for your attention
There is no need to put any delay to Beanshell Pre-Processor as it's being executed before request. I'd recommend to check your jmeter.log file to see if there are any scripting issues as Beanshell Pre-Processor does not report errors anywhere including View Results Tree listener.
There are at least 2 ways to assure that everything is fine with your Beanshell script:
Put your debug print code after variables replace logic to see if it fires
Use JMeter __Beahshell function right in your HTTP request. If it's ok - View Results Tree will demonstrate beanshell-generated value. If not - the field will be blank and relevant error will be displayed in the log.
Example test case:
Given following Test Plan structure:
Thread Group with 1 user and 1 loop
HTTP GET Request to google.com with path of / and parameter q
If you provide as parameter "q" following beanshell function:
${__BeanShell(System.currentTimeMillis())}
and look into View Results Tree "Request" tab you should see something like:
GET http://www.google.com/?q=1385206045832
and if you change function to something incorrect like:
${__BeanShell(Something.incorrect())}
you'll see a blank request.
The correct way of changing existing variable (or creating new if variable doesn't exist) looks like
vars.put("variablename", "variablevalue");
*Important: * JMeter Variables are Java Strings, if you're trying to set something else (date, integer, whatever) to JMeter Variable you need to cast it to String somehow.
Example:
int i = 5;
vars.put("int_i", String.valueOf(i));
Hope this helps.
You can update the vale of a "user defined variable".
You have to create a bean shell sampler
vars.put("user_defined_variable", "newvalue");
#theINtoy got it right.
http://www.blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell
I'm new to jmeter too but as I know variables defined in "User defined variables" are constants, so you can't change them. I recommend to use "User Parameters" in preprocessors or CSV Data Set Config.

Reference a variable within a variable in JMeter

I'm working with JMeter. I'd like to specify the test host using user defined variables, like this:
variable name value
localhost localhost
test 192.168.0.1
hostname ${localhost}
Executing the test, I see that the hostname value is not substituted, and obviously the test fails. I know I can use properties and pass the hostname from the command line, or simply change the hostname value. Is it possible to it like I've explained?
Thanks.
I've managed to solve my problem. I've changed the hostname variable value to: ${__evalVar(${localhost})}, but I've got this error:
ERRROR jmeter.functions.EvalVarFunction: Variables have not yet been defined
So I've moved the hostname variable declaration in a "User defined variable" child node of my Sampler node. That solved it.
To solve this you should use hostname = ${__eval(${localhost})}
http://jmeter.apache.org/usermanual/functions.html#__eval
Carlos' answer has a mistake (which I can't comment on due to rep) as it uses evalVar, this requires as an argument a plain string:
This works: ${__evalVar(localhost)})
This works: ${__eval(${localhost})}
This doesn't work (the current answer): ${__evalVar(${localhost})}
http://jmeter.apache.org/usermanual/functions.html#__evalVar
Check this forum:
from Blazemeter
For example: getting value of varible "listid_XXX" where the XXX number comes from an index variable:
${__V(listid_${idx1})}
New newer versions (from 2.2), you can use ${__V(${...})}/.
Ex: ${__V(${SERVER_CONTEXT})}/rest
As #Alies Belik mentioned, if you get
ERRROR jmeter.functions.EvalVarFunction: Variables have not yet been defined
then define the 2nd variable in next other UDV (User Defined Variables) node.