What is "0E-20" - testing

Im using a Model Based Testing tool (Conformiq).
It generates test cases with value "0" but when i export those test cases in java, the value written there is "0E-20"
What does that mean? What is "0E-20" ?
the code is somwhat like this :
new CQRecordNumber(
/** value */
(float)0E-20));

As per this Wiki page, xEy means x * 10^y, which, in your case, is 0 * 10^(-20)

Related

Calling feature file within another feature file using tags [duplicate]

We have a feature A with several scenarios. And we need one scenario from that file. Can we call it in our feature B?
No. You need to extract that Scenario into a separate*.feature file and then re-use it using the call keyword.
EDIT: Karate 0.9.0 onwards will support being able to call by tag as follows:
* def result = call read('some.feature#tagname')
To illustrate the answer from Karate-inventor Peter Thomas with an example:
Given a feature-file some.feature with multiple scenarios tagged by a tag-decorator:
#tagname
Scenario: A, base case that shares results to e.g. B
// given, when, then ... and share result in a map with keyword `uri`
* def uri = responseHeaders['Location'][0]
#anotherTag
Scenario: X, base case that shares results to e.g. B
// given, when, then ... and share result in a map with keyword `createdResourceId`
* def createdResourceId = $.id
In another feature we can call a specific scenario from that feature by its tag, e.g. tagname:
Scenario: B, another case reusing some results of A
* def result = call read('some.feature#tagname')
* print "given result of A is: $result"
Given path result.uri + '/update'
See also: demo of adding custom tags to scenarios

Can we use '#ContinueNextStepsOnException' to run all the steps in the Karate script instead of karate.match(actual, expected)

I have a response with hundreds of attributes while matching the attributes the scripts getting failed and further steps are not getting executed. because of this we have to validate the same case multiple times to validate the attribute values. is they a option like #ContinueNextStepsOnException to execute all the steps and it is hard to script using karate.match(actual, expected) for more than 100 attributes I have give actual and expected values if in case of any failure to continue.
No, there is no such option. If your scripts are getting failed - it is because Karate is doing its job correctly !
If you feel you want to skip certain fields, you can easily do so by using match ... contains syntax.
I think you are using multiple lines instead of matching the entire JSON in one-line which you can easily do in Karate. For example:
* def response = { a: 1, b: 2 }
# not recommended
* match response.a == 1
* match response.b == 2
# recommended
* match response == { a: 1, b: 2 }
Is it so hard to create the above match, even in development mode ? Just cut and paste valid JSON, and you are done ! I have hardly ever heard users complain about this.

Can we call a scenario from one feature in another using karate?

We have a feature A with several scenarios. And we need one scenario from that file. Can we call it in our feature B?
No. You need to extract that Scenario into a separate*.feature file and then re-use it using the call keyword.
EDIT: Karate 0.9.0 onwards will support being able to call by tag as follows:
* def result = call read('some.feature#tagname')
To illustrate the answer from Karate-inventor Peter Thomas with an example:
Given a feature-file some.feature with multiple scenarios tagged by a tag-decorator:
#tagname
Scenario: A, base case that shares results to e.g. B
// given, when, then ... and share result in a map with keyword `uri`
* def uri = responseHeaders['Location'][0]
#anotherTag
Scenario: X, base case that shares results to e.g. B
// given, when, then ... and share result in a map with keyword `createdResourceId`
* def createdResourceId = $.id
In another feature we can call a specific scenario from that feature by its tag, e.g. tagname:
Scenario: B, another case reusing some results of A
* def result = call read('some.feature#tagname')
* print "given result of A is: $result"
Given path result.uri + '/update'
See also: demo of adding custom tags to scenarios

How to pass variable to groovy code in Intellij IDEA live templates groovy script?

I have a groovyScript in my Intellij IDEA live template, like this :
groovyScript("D:/test.groovy","", v1)
on my D:/test.groovy i have a code like this:
if ( v1 == 'abc') {
'abc'
}
Now I want to pass v1 variable into test.groovy ,can any one help me how can I do this?
For exemplification purposes I made a live template which is printing a comment with the current class and current method.
This is how my live template is defined:
And here is how I edited the variableResolvedWithGroovyScript variable:
The Expression for the given variable has the follwing value:
groovyScript("return \"// Current Class:\" + _1 + \". Current Method:\"+ _2 ", className(),methodName())
As you can see, in this case the _1(which acts like a variable in the groovy script) takes the value of the first parameter which is the class name, and the _2 takes the value of the
second parameter which is the method name. If another parameter is needed the _3 will be used in the groovy script to reference the given parameter.
The arguments to groovyScript macro are bound to script variables named _1, _2 etc. This is also described at groovyScript help at Edit Template Variables Dialog / Live Template Variables.
I found a solution.
I was needing to calculate a CRC32 of the qualified class name using live models
I used it like this:
groovyScript("
def crc = new java.util.zip.CRC32().with { update _1.bytes; value };
return Long.toHexString(crc);
", qualifiedClassName())
then the result is
Based on the documentation, your variables are available as _1, _2, etc. Please note that variables are passed without dollar signs (so only v1 instead of $v1$)
So your test script should look like
if ( _2 == 'abc') {
'abc'
}

How to access a stored value in PHPUnit_Extensions_SeleniumTestCase

How can I store a value within Selenium-RC (through PHPUnit) and then retrieve/access it later using PHPUnit?
Suppose I run a command like the following in a test:
$this->storeExpression( "foo", "bar" );
If I understand the Selenium API documentation correctly, I could access this data using javascript{storedVars['foo']} using good 'ol fashioned Selenese. It should contain the value "bar".
My question is this: how can I access this javascript{storedVars['test']} expression (or, more generally, javascript{storedVars} in PHPUnit?
For example, here's a simple test I've run:
public function testStorage()
{
$this->open('http://www.google.com/'); // for example
$this->storeExpression( 'foo', 'bar' );
$foo = $this->getExpression('foo');
echo $foo;
}
The output of which is "foo" (among the other standard PHPUnit output), while I expect it should be "bar". It's just giving me back the name of the expression, not its value.
Can anyone with experience in this give me some guidance?
Good posts in this thread, but looks like no 100% working answer so far.
Based on the Selenium reference here
http://release.seleniumhq.org/selenium-core/1.0/reference.html#storedVars
It would seem the correct code syntax would be:
$this->storeExpression( 'bar', 'foo' );
$foo = $this->getExpression("\${foo}");
I haven't tested that exactly, but doing something similar with
$this->storeHtmlSource('srcTxt');
$val = $this->getExpression('\${srcTxt}');
print $val;
did the trick for me.
The PHPUnit Selenium Testcase driver actually understands storeExpression and getExpression; have a look at its source code. You can do
$this->storeExpression('foo', 'bar');
and
$this->getExpression('foo');
As Selenium Stores the expression result in second argument it stores value in "bar" and when u need to call it you should call the stored name to get the expression.
$this->storeExpression( 'foo', 'bar' );
$foo = $this->getExpression("bar");
May this helps you it worked for me.
EDIT :
$evaluated = $this->getEval("regex:3+3");
$expressed = $this->getExpression("regex:3+3");
The First Evaluated will give the evaluated output for expression
and the second will show the expressed output.
The secound is used to verify that the specified expression is genrated or not by the alert.