A chain with Action.Dependent throws JqwikException: empty set of values - jqwik

I am doing stateful testing using Jqwik. The problem I am facing is as follows:
The action chain contains a set of state dependent actions that can produce empty Arbitraries (example: no "pop" action should be produced for an empty stack). Some actions are state independent and are always "productive" (like "push" a value on the stack).
The issue is that action chains are generated randomly and sometimes only non-productive actions are selected which in turn produces empty chains and ends up in the net.jqwik.api.JqwikException: empty set of values.
Increasing weight on "productive" actions mitigates the issue but does not solve it.
Is there a way to make sure at least one "productive" action is always selected and hence the generated action chain is always non-empty?
I've tried to use ActionChain.independent() with endOfChain() transformer but it did not help.

As mentioned by johanneslink - I should implement Action.precondition() for this purpose. Thanks.

Related

Is it possible to create a bound between 2 views so their z-index is always next to each other?

Is there a way for me to have two views that always remain one on top of the other no matter what gets added?
For example I want to have ViewA contains ViewA1 and ViewA2. and if I decide to add a viewA3 below ViewA1 it won't be added right below it but below the next that is not "constrained" to be below ViewA1.
So ViewA1 and ViewA2 need to always be together and if I try to add a ViewA3 under ViewA1 it will go under ViewA2 instead.
Sort of like a constraint on the z axis between views.
I've tried observing for zPositions, tried to observe changes on the subviews of the superview. No success yet. Any tips are welcome!
I've managed to find a working solution for this — it's possible to observe my superview.layer.sublayers for any changes. Then it's just a matter of making sure the layer of my viewA1 is always near the layer of viewA2.

Forget second input in action when prompt for first input is responsed

I have my code in following structure:
action(app){
//two inputs in this action
1.InvocationName
2.MenuOptionValue //(Action1,Action2,Action3)
//output
Selected Menu Option operation
}
I am new to Bixby , I have following Two Questions:
1.When I give directly only menu option(2nd Input), it prompts me for Invocation name(1st Input) which is trained in NL ,and then I give invocation name and it starts output operation,which it should .But, here I want it to forget the previous Menu Option (2nd input) and prompt me for it again.Is it possible in this structure or suggest if possible in other structure way.
2.MenuOption have 3 options(Action1,Action2,Action3) which should redirect to 3 different operation on input.
Though i am printing in js (endpoint) on different inputs.But how will i perform another following action(User Interaction with Bixby) for those operation,saving previous data.Is it possible by this structure or any suggestions?
For question #1, please give concrete example. I don't understand what you want to do here. I will update my answer when you provide more content. Maybe as answer to question #2, remodeling your capsule to three actions each with different input solves this issue as well. Action would be isolated from each other, so there is no remember or forget issue.
For question #2, if 3 different actions requires different input method, for example, one is integer, and one is string or maybe the third is an integer plus string, you should consider make them different actions and link to separate JS file in endpoints. Then you can treat each action differently by adding different follow-up. Make sure you add training utterances for each of the actions. It is recommended that one action model in Bixby should handle, well, one action only.

Microsoft Flow Execution Order

I have created a bunch of short flows that act on a single SharePoint list item to reduce complexity, but I've run into a problem with the order in which they execute. I think I could best explain this with an example, so please see below:
Let's say there are three flows, SetTitle, SetPermissions, and SendEmail (sends an email based on the new value after a column changes). Ideally, SetPermissions would run first, then SendEmail, and finally SetTitle since it modifies the item. That modification is a problem because it adds a version to Version History, which I am checking in the SendEmail flow to see if the value of a column changed.
Currently, however, SetTitle sometimes runs first, which breaks SendEmail because now the most recently displaced version does not contain a record of the column change that happened two versions ago.
I would like to avoid creating additional columns in the item to track column changes or emails sent, because we're creating these flows to avoid that messy complexity.
I'm hoping that there is some hidden execution order option somewhere, because as I said, I don't really want to create extra columns or trigger flows based on HTTP calls. Of course, what I'm doing now isn't working, so I understand that I may have to compromise.
I do not think what you are looking for is possible tbh.
I know you said you do not want to create more columns, but the only solution that I can think of requires only 1 extra column to be created. Use that to run the flows in the right order.
For example, if there are two flows: f1 and f2, set the default value of the new column(let's call it 'stage') to 0. Then, add a condition to f1 so it only runs when the stage is 0 and also updates the column to 1. Then f2 also has an initial condition check and runs only when 'Stage' is '1' and also sets 'Stage' to '2'.
Hope this helps.

How to refer same DataTable across different features in cucumber-jvm?

In one of step definitions I have created a function say “someFunction” that takes a DataTable, which has been defined in my feature file Feature1.
Feature1.feature
Given: User enters the following data
Varibale1|Variable2|Variable3
Value1|Value2|Value3
StpeDef.java
#Given(“^User enters the following data$”)
public void someFunction(DataTable input){
}
Now in another feature file “Feature2.feature”, one of my scenario needs to use same step i.e. call someFunction. I know I can use the same step definition but does that mean that I would have to redefine same DataTable input in Feature2 file.
If not, how would I do it?
Please note that I understand the Backgound keyword and its use, but if I say I need to keep these scenarios in different feature files, how should this be done?
You'll have to duplicate the common background. Since duplication is unwanted, you should consider giving a name/title to the resulting state that is represented by that common background and create a single given step that can be re-used. Something like "Given: the user has entered valid contact data" or "Given: the shopping cart has 3 items" (where any 3 will do).

In PyQt, I need to handle both itemClicked and itemSelectionChanged, but not both at the same time

I've created a QTreeWidget that displays data that's pulled from 3rd party API calls.
I want the data to be fresh when the user either clicks on or uses the arrow keys to navigate to any QTreeWidgetItem. This means making an API call each time the user clicks or uses an arrow key. Importantly: If the user clicks on the same item a second time, I would like the item to display fresh data (in other words, make another API call and populate with new data, aka refresh)
So far, I've tried:
connecting both itemSelectionChanged and itemClicked to the same update function. This works, but it means that for every click on a new QTreeWidgetItem, I get two calls to the update function (one from itemClicked and the other from itemSelectionChanged), and therefore two API calls that do the exact same thing. Not ideal.
Only handling itemClicked, but then using an event filter to look for Key_Up or Key_Down and then manually emitting an itemClicked. The problem with this is that the key event is handled before the selection is changed, so when using the arrow keys, I'm always getting data for the last QTreeWidgetItem selected, not the current QTreeWidgetItem.
I thought about creating a very short timer or a flag and starting/setting at the start of the update function. If the timer is running or the flag is set, don't run the function (the idea being that the first slot would run, but the second would not because the flag is set/timer is running), but that seems both sloppy and prone to race conditions.
Unfortunately, using a QTreeView with a QAbstractItemModel is not an option.
With that, is there any way to handle both a repeated click on the same item and arrow keys to select new items without double-calling the same update function?
As #ekhumoro pointed out, this can be done by handling both itemClicked and itemSelectionChanged, but introducing some logic so that both functions don't run at the same time.
When a user clicks on the widget, an itemClicked signal is fired. When the user changes selection, the itemSelectionChanged signal is fired. In my case, then, I've created two slots (functions): update (a slot for itemSelectionChanged) and updateFromClick (a slot for itemClicked). updateFromClick checks to see if the selection has changed (this means you always have to store and keep track of the current selection). If, in updateFromClick, I see that the selection has changed, then I do nothing, as update will have been called from itemSelectionChanged. If, in updateFromClick, I see that the selection has not changed, I know that itemSelectionChanged has not been fired, so I call the update function explicitly from updateFromClick.
Again, this is just a long-winded version of #ekhumoro's comment that I'm putting here so the question doesn't go unanswered.

Resources