FAQ Database Discussion Community


SoapUi Assertions - Use a string as a json path with groovy

json,string,groovy,soapui,assertions
I am using groovy to automate some tests on SoapUI, and I wanted to also automate assertions in a way I would get a field's name and value from a *.txt file and check if the wanted field does exist with the wanted value in the SOapUI response. Suppose I...

Clojure condition-map parameter provided as metadata of the arglist

clojure,assertions,assertion,design-by-contract
In the the special forms Clojure documentation (http://clojure.org/special_forms) The condition-map parameter is described as below: The condition-map parameter may be used to specify pre- and postconditions for a function. It is of the following form: {:pre [pre-expr*] :post [post-expr*]} where either key is optional. The condition map may also be...

Dollar Object intricacies

c#,tdd,assertions
I am reading Kent Beck's book "Test Driven Development: By Example." In his book, there is a coding example: public class Dollar { public int _amount; public Dollar(int amount) { _amount = amount; } public Dollar Times(int multiplier) { return new Dollar(_amount *= multiplier); } } [TestMethod] public void TestMethod2()...

Why assertion is not enabled by default in java? [closed]

java,assertions
By default assertion is not enabled so we have to enable it by passing -ea as jvm argumentso, Why it is not enabled by default? What is the exact use of it? If we enable does it cause performance or any other issue? ...

Java Assertion in Try with multiple catchs

java,exception-handling,assert,assertions
Scenario: class Assert { public static void main(String []args) { try { assert false; } catch (RuntimeException re) { System.out.println("In the handler of RuntimeException"); } catch (Exception e) { System.out.println("In the handler of Exception"); } catch (Error ae) { System.out.println("In the handler of Error"); } catch (Throwable t) { System.out.println("In...

Does $stable in SystemVerilog Operate on Buses?

system-verilog,assertions
I would like to verify that a bus is stable in an assertion. For example, I would expect the following assertion to flag an error if data changes in the clock after the re falling edge. wire clk, rst_n, re; wire [15:0] data; a_chk_stable_data: assert property (@(posedge clk) disable iff(!rst_n)...

Assertion to verify a glitch in a signal

system-verilog,assertions
Lets say there is a signal a . When the signal goes high, it has to stay high at least for three positive clock edges. We can write the property as property p; @(posedge clk) $rose(a) -> a[*3]; endproperty The property fails for the case below. clk _ _ _...

Wilcards not working for XQuery assertions in SoapUI

xpath,groovy,xquery,soapui,assertions
This is the response for one of my test steps: <Names> <NameList PropertyName="Record"> <Names> <SimpleValue Value=" Date: MM/DD/Year "/> <SimpleValue Value="Name: John "/> <SimpleValue Value="Amount: 1234"/> <SimpleValue Value="Change: 2.0 "/> <SimpleValue Value="Total: 0.0 "/> </Names> </NameList> </Names> I'm expecting the exact match in my Xquery assertion except the value where...

Assertion when declaring required arguments with argparse and 'nargs=*' arguments

python,argparse,assertions
Here is the current code to parse the arguments : parser = argparse.ArgumentParser() parser.add_argument('-a', '--action', required=True, metavar='', nargs=1, help='{block|release|clear|show|show_extended|}') parser.add_argument('-i', '--interface', required=True, metavar='', nargs=1, help='interface name') parser.add_argument('-d', '--debug', action='store_true', help='debug prints') parser.add_argument('--ips', metavar='ips', nargs='*', help='ip addresses to block') parser.add_argument('--handles', metavar='handles', nargs='*',...

Assert arrays in Protractor

arrays,compare,jasmine,protractor,assertions
I am working on E2E tests and my goal is to compare two arrays. I set these arrays so that they are identical. The problem is that Protractor doesn't think they are same. My code: expect(arrPuv).toBe(arrNov); Console output: Error: Expected [ '1 patro', '2. Patro', 'asdf', 'My precious', 'My precious',...

Checking two boundaries with Jasmine (between matcher)

javascript,testing,jasmine,assertions,jasmine-matchers
In Jasmine, there are toBeGreaterThan and toBeLessThan matchers. What if I want to check an integer value in a specific range? Is there anything like toBeInBetween matcher? Currently, I can solve it in two separate expect calls: var x = 3; expect(x).toBeGreaterThan(1); expect(x).toBeLessThan(10); ...

Could Assertions be used for maintaning loop invariants and checking program correctness

java,if-statement,assertions,invariants
I recently saw this question and thought that the person who asked question is correct to some degree. The answer informed that we should not use assertions to perform any tasks in our program. But assertions can act as easy one liners for maintaining loop invariants and program invariants ,...

How to fail a script assertion in SoapUI?

soapui,assertions
I'm trying to let a script assertion fail, when a variable has another value than defined. My goal: Mark the TestStep as red, if the TestStep will fail. Please note that I am using a script assertion for a TestStep - not a separate Groovy-Script TestStep. My script looks like...

SOAP-UI: How to get CDATA XPath for an assertion?

xml,xpath,groovy,soapui,assertions
I have a SOAP UI project that has the following web service response: <env:Envelope env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <env:Header/> <env:Body> <m:invokeResponse xmlns:m="some namespace"> <result xsi:type="xsd:string"><![CDATA[<?xml version="1.0" encoding="US-ASCII"...

NodeJS function parameter checking with assertions

javascript,node.js,assertions
NodeJS' dynamic typing is fun and all but given a function I'd like to get some feedback during development whether what I'm passing is in fact going to produce anything meaningful. In C# I would do: Debug.Assert(complexType.Title.length <= 10) (such statements would not be included when compiled in release mode)...

How to use throughout operator in systemverilog assertions

system-verilog,assertions
Here is a spec: If signal a is asserted then it must be asserted till signal b is asserted and then it should de-assert on next clock edge. I'm reading through 16.9.9 of LRM (as well as http://www.testbench.in/AS_06_SEQUENCES.html) and the way I understood it, above mentioned spec can be written...

Is grouping preconditions into a method acceptable to stay DRY?

c#,assertions,preconditions
When writing preconditions for different functions with similar parameters, I want to group assertions or exceptions into a static method, rather than writing them out explicitly. For example, instead of GetFooForUser(User user) { assert(null != user); assert(user.ID > 0); // db ids always start at 1 assert(something else that defines...

Any way to show assertEquals error message along with the given custom message in TestNg soft assertion

testng,assertions
Here's a link Is there any way to display the default assertEquals error message along with the custom message given in soft assertion? My requirement is to have custom message and assert error message as below. "brokedown expected [1] but found [0]" import org.testng.annotations.Test; import org.testng.asserts.SoftAssert; public class SoftAsert {...

How to write pulse width systemverilog assertion when width is configurable

system-verilog,assertions
The scenario is: Signal active can be either 1 cycle, 2 cycle, 3 cycle or 4 cycle wide depending on config[1:0] input to the module Easiest way to write property for this is: property p_PropA; @(posedge clk) $rose active ##config ~active; endproperty But it is syntactically wrong. What is correct...

$assertionsDisabled and javac standards compliance

java,compiler-errors,assertions,standards-compliance,name-collision
I was wondering how assertions were implemented. I found that javac uses a static field $assertionsDisabled. And I was curious what will happen if $assertionsDisabled is already used. public class Test { static final boolean $assertionsDisabled = Math.random() < .5; public static void main(String[] args) { assert false; } }...

.NET assert assertions are enabled

c#,.net,assertions
How does one assert that assertions are enabled in C#? Here's a link to a related answer for Java, that does not work in C#. The purpose of this would be to prevent the use of release-type assemblies because where efficiency is of no concern I might as well be...

Expressive assertion failure messages in C++

c++,unit-testing,assertions,verbosity
Unit test frameworks generally provide very nice assertion failure messages (I'm using gtest) describing expected and actual values to a particular test. Furthermore, you know the origin of the function call because you're testing the interface of the class. In contrast, assert, when used as a sanity check in the...

static_assert fails check on templated object pointer

c++,templates,c++11,assertions,static-assert
template <size_t N> class Foo { static_assert(N > 0, "WRONG"); //void Something() = 0; //my original implementation }; int main() { Foo<0> *p2 = nullptr; //no error Foo<0> p; //gives an error return 0; } I've tested both the lines separately. static_assert is not called when p2 is initialized but...

importing VHDL packages to SV from libraries other than WORK

vhdl,system-verilog,assertions
I have a VHDL module that is compiled to a library, say, LIB_A. The module has ports that are records, the corresponding type is defined in a package that is also compiled into LIB_A. I would like to write some assertions for the module and check them using OneSpin. At...

Does enabling Java assertions increase memory consumption significantly?

java,assertions,jvm-arguments
I've been working on a Java program that reads large CSV files, processes the contents, and submits it to a Solr server depending on certain criteria. The code has been working fine for some time with an initial data set. But as it has not been tested extensively, so I...

Assertion error when passing object by value — it is my copy constructor?

c++,vector,copy-constructor,dynamic-memory-allocation,assertions
everyone! I just finished writing a 2-D maze (Class is an ADT titled "Maze"--how original) that uses dynamic memory allocation. I'm passing the Maze to a method of another class I've entitled "MazeSolver," which uses recursion and backtracking to solve the maze. Good news is my code compiles wonderfully when...

Custom FEST Assertions : Displaying readable message with

java,junit,testng,assertions,fest
I have created a custom FEST Condition to verify that my actual string either matches or is equal to an expected String public class StringMatchesOrIsEqualTo extends Condition<String>{ private String expectedStringOrExpression; public StringMatchesOrIsEqualTo(final String expectedStringorExpression){ this.expectedStringOrExpression = expectedStringorExpression; } @Override public boolean matches(String value) { return value.matches(expectedStringOrExpression) || value.equals(expectedStringOrExpression); } }...