Opentelemetry context propagation test - metrics

I'm trying to test some opentelemetry spans are correctly build and linked in parent child relations.
clientSpan = Span.wrap(
SpanContext.createFromRemoteParent(
"12345678123456781234567812345678",
"1234567812345678",
TraceFlags.getDefault,
TraceState.getDefault
)
)
.updateName("clientSpan")
And the code which I want to test creates a new span which is the child span of the client span which it receives
tracer.spanBuilder("my-endpoint")
.setSpanKind(SpanKind.SERVER)
.setParent(Context.current().`with`(clientSpan))
.startSpan()
My problem is that whenever I pass the clientSpan the
InMemorySpanExporter.getFinishedSpanItems() returns empty.
It returns non-empty and as expected when no clientSpan is used.
In the unit test i tried both ending the parent span or leaving it open: clientSpan.end() but getFinishedSpanItems is always empty.
Maybe I'm not building correctly the clientSpan in my unit test ? (in prod code it gets extracted from the carrier-propagator-getter combo)

The wrap returns a non-recording span that contains the provided span context but has no functionality. All the operations are no-op. So whatever you do clientSpan has no effect.
Please change the TraceFlags.getDefault() to TraceFlags.getSampled(). The default returns a flag with all bit off which means the no child spans will be considered

Related

What would be an easy way to check if a `q-input` element is in a error state?

I have q q-input with a data-cy="inputEmail" property
Is there an easy way to check if the q-input is in an error state ?
The data-cy prop is attached to the native input element and it looks like the only way is to use some relatively complex css selectors, for instance by checking if the input's parent's parent has a text-negative class ?
Ideally from an e2e perspective you want to test for what a user sees, for the presence/absence of the error message
cy.get('[data-cy="inputEmail"]')
.parent('.q-input')
.should('contain', 'must be a valid email')
If you look at the DOM, nothing changes on the input itself.
So assuming that in the error state text-negative class is added to the element, so you can assert the presence of this class like:
cy.get('q-input selector').should('have.class', 'text-negative')

Ruby cucumber automation suite - parameter received as null while iterating

I inherited a test automation suite and while modifying it I am trying to write a function to test similar links which are present in the same web page but in different divs and the tag ids are dynamic.
I have a function defined below which accepts an HTML element and sends an action to the element
def element_do(html_element, html_element_type, html_element_value, action)
#browser.send(html_element.to_sym,html_element_type.to_sym ,html_element_value).send(action)
end
I have a method defined as somemethod and I am trying to call the method in a particular div using the some_element#{i} as below
def multiple_accounts
#num_accts.each do |i|
p "validating for account #{i}"
#page.element_do(:div,:id,"some_element#{i}",somemethod)
end
The issue I am facing is that on second iteration the action parameter is passed as null instead of the somemethod. I am new to ruby automation and I am not sure what exactly is happening. Any help is appreciated
Additional details - based on the questions
1) #num_accts is an array which is got by scanning the text of the webpage and contains account numbers (eg: [56544, 87990])
2) This forms a part of the id for the divs as in "acct#56544". So I am passing the array elements from num_accts to "acct#{i}" referred as 'some_element'
3) 'Somemethod' is a method defined to click on a particular link in the div and verifies a text to confirm that the link redirects to the correct page. The some method works fine when there is only one div.
It is not evident from the question, but my suspicion is that you try to pass the name of the method (which returns null), but instead you call the method. I think your call should be:
#page.element_do(:div,:id,"some_element#{i}",'somemethod')

Test Cases fails if any of them fails

I am trying mocha test case to check rest api, but the issue is if I have 3 test cases and first one fails then rest are not executing. It stops at first only.
Here is following code:
describe('suite 1',function(){
it('tc1',function(done){
// some test case with failure
should([1]).equal([]);
done();
})
it('tc2',function(done){
// some test case with success
should([]).equal([]);
done();
})
})
In above code I am not able to get report like
2 test cases.
1 Passed.
1 Fail.
It fails in middle, in here it fails on first test case only.
Both tests are failing because they both should fail.
The both tests fail because you are using equal which checks for object identity. That is, it uses === to check for the equality. Now, open an interactive Node session and try this:
[] === []
You'll get false. That's because each new empty array is a new JavaScript object and === will be true only if the two arrays are the same object.
Note that you get the result you expect in your first test but not for the reason you (probably) think. The test fails for the same reason I've just explained. The fact that one array contains an element but the other is empty is not taken into account by should.
You should use eql to test whether the arrays have the same members.

CodedUI assert a nonexistent element

my problem is that I want to check that an element is not displayed. In other words I want to check that an element was deleted.
So I am developing an automatic test that has a option to disable comments. I want to check that the textfield for the comments is nonexistent. Is there any easy way to do this?
You need to distinguish between the element (a text field or something) being not displayed and it being empty.
If the field is displayed but is empty then a simple assertion that the value is the empty string will work.
If the field is not displayed at all then an attempt on an assertion will fail with a control not found exception. The relevant code can be enclosed within a try-catch block that expects to catch the exception
try {
... access the control...;
Assert.Fail("The control was found but it should not be present.");
}
catch (UITestControlNotFoundException ) {
// Success path.
}
Make sure that the ... access the control...; checks for the correct level in thy control hierarchy. You may also want to enclose it with code to fail quickly when the control is not present, by default Coded UI may wait in case the application is slow to draw the control.
Try this :
Bool isExists = (Boolean)BrowserWindow.ExecuteScript("return $('#yourcontrolId').length > 0;");
if(isExists)
Assert.Fail("Control is not deleted");
// Success Code

How to provide AppleScript support to 'make new' element with one of its own elements

I am using the 'newScriptingObjectOfClass…' method within my application delegate's class in order to accommodate core data. I can 'make' the container element 'level' just fine, however I haven't a clue how to 'make' the element with one of its own elements. In order to make a new 'unit'--an element of 'levels'--I have to refer back at the containing 'level', which is circular logic.
Here's what seems to be the right way to create my new level, however the 'make' command does not provide the term 'element' as a parameter term for 'level' element, 'unit'.
tell application "SpellAnalysis"
make new level with make new element unit
end tell
Here's what my 'sdef' file shows:
level n : Application levels collection
elements
contains units; contained by application.
unit n [inh. level] : Level's unit collection syn unit
elements
contains sections; contained by levels.
Also noteworthy is that my KVC method is never called from the 'newScriptObjectClass…' method when I successfully make a new 'level' (without a contained 'unit'):
- (void)insertObject:(id)entry inLevelObjectsAtIndex:(NSUInteger)index {}
This compiled for me:
tell application "SpellAnalysis"
((make new level with «class») make new element with unit) // syntax 1
((make new level in class) make new unit with element) // syntax 2
end tell
end tell
you'll likely need to tweak it a bit, but that's the general idea for syntax. when i tried your example i got:
'expected “into”, variable name, class name, other parameter name or
property but found command name.'

Resources