Can I execute all my Karate feature files more than once based on a parameter [duplicate] - json

This question already has an answer here:
How can we execute WebUI feature file against multiple browsers using parallel runner or distributed testing?
(1 answer)
Closed 1 year ago.
We have a requirement to run the entire test suite more than once considering different parameters.
Say, I have 5 feature files and each has 10 scenarios. I have a requirement to run these feature files twice one after the other.
There is a way to achieve this using Scenario Outline, which will execute each scenario for the number of parameters. But can we have all the scenarios run once for the 1st parameter and then all the scenario again for the 2nd parameter. Something like an Outline at Feature level.
Please suggest.

I think this should be done at the JUnit / Java runner level. Teams usually use tags to enable or disable features at run time.
Or you can create a "wrapper" feature that calls a second feature etc.
Otherwise please assume that what you want is not directly supported, you are welcome to contribute code to Karate if needed. My honest opinion is that this is not required in a testing framework, maybe you should just write code.
EDIT - see this answer, I think you will be able to figure out an approach based on it: https://stackoverflow.com/a/60387907/143475 - and keep in mind Karate supports a "dynamic" Scenario Outline.

Related

Cucumber examples reuse in different features/scenarios

I've been using cucumber for awhile and I've stumbled upon a problem:
Actual question:
Is there a solution to import the examples from a single file/db using cucumber specifically as examples?
Or alternatively is there a way to define a variable while already in-step to be an example?
Or alternatively again, is there an option to send the examples as variables when I launch the feature file/scenario?
The Problem:
I have a couple of scenarios where I would like to use exactly the same examples, over and over again.
It sounds rather easy, but the examples table is very large (more specifically it contains all the countries in the world and their appropriate continents). Thus repeating it would be very troublesome, especially if the table needs changing (I will need to change all the instances of the table separately)
Complication:
I have a rerun function that knows when a specific example failed and reruns it after the test is done.
Restrictions:
I do not want to edit my rerun file
Related:
I've noticed that there is already an open discussion about importing it from csv here:
Importing CSV as test data in Cucumber?
However that discussion is invalid to me because I have the rerun function that only knows to work only with examples, and the solution suggested there ruins that.
Thank you!
You can use CSV and other external file systems with QAF using different BDD syntax.
If you want to use cucumber steps or cucumber runner, you can use QAF-cucumber and BDD2 (preferred) or Gherkin syntax. QAF-cucumber will enable external test data and other qaf features with cucumber.
Below is the example feature file uses BDD2 syntax can be run using TestNG or Cucumber runner.
Feature: feature uses external data file
#datafie:resources/${env}/testdata.csv
#regression
Scenario: Another scenario exploring different combination using data-provider
Given a "${precondition}"
When an event occurs
Then the outcome should "${be-captured}"
testdata.csv file may look like:
TestcaseId,precondition,be-captured
123461,abc,be captured
123462,xyz,not be captured
You can run using TestNG or Cucumber runner. You can use any of inbuilt data provider or custom as well.

Spring-Roo Push In via Command Line

I need to perform push-ins for my json controllers, however, doing it via STS will make it really tedious. For my demo project, it works since it only contains 10 pojos, but for real world project this may become 20-50 pojos.
Is there a way to perform push-ins via command line or any way to automate it?
I am asking due to my previous issue which cannot be solved by spring-roo's current version :
RooWebJson and KendoUI Grid
No, there is no way to push-in code via command line. The best way is to use STS, but note you will push-in the code only one time.

Running junit tests in intelliJ in parallel [duplicate]

This question already has answers here:
Running JUnit Tests in Parallel in IntelliJ IDEA
(3 answers)
Closed 5 years ago.
Is it possible to run junit tests in intelliJ in parallel? If so, how do i do this?
I set the "fork" parameter to class level and this didn't do anything - actually, it made everything a bit slower, so i'm unsure what "fork" does that is beneficial?
Is it possible to do this just using intelliJ, or do i need some fancy test framework and all the hoo-hah that that would involve?
Finally, assuming this is at all possible, can one control the number of forks or threads or whatever they want to call it?
UPDATE: somebody has linked to a question that might answer this. I looked at that question prior to posting - I'm unsure what that question really "answers". It simply says there is an issue tracker and that this issue has been implemented in intelliJ. I don't see how to implement it anywhere.
UPDATE: What does "didn't do anything" mean?: it just makes things slower, which isn't v. useful. I mean, maybe your tests run blazingly quickly and you want to slow them down to appreciate some Bach? That is cool. I just want mine to run faster, I'm fed up of Bach.
You can make use of the junit-toolbox. This is an extension library for jUnit that is listed on the jUnit site itself.
This extension offers the ParallelSuite. Through this you can create with nearly no effort an AllTest class that executes the tests in parallel. The minimum AllTest could look like the code below, using the pattern feature introduced with junit-toolbox.
#RunWith(ParallelSuite.class)
#SuiteClasses("**/*Test.class")
public class AllTests {}
This will create as many threads for parallel execution as your JVM reports via availableProcessors. To override this you may set the system property maxParallelTestThreads.

Is there an easy way to convert to PDO

On my website I use both a postgresql and mysql database
I want to convert to PDO as I have been informed that PHP will be removing the old mysql_ functions soon and I assume this means the pg_ functions will disappear as well.
I only ever use:
pg_connect/mysql_connect & mysql_select_db
pg_query/mysql_query
pg_result/mysql_result
pg_numrows/mysql_numrows (for checking if there is a result, or looping through resultset)
pg_fetch_array
I have thousands of queries and don't relish the idea of going through every one.
Is it possible just to go through and make global changes in my code to implement PDO?
Does that mean I can just do a global change mysql=mysqli in the interim?
Well the answer is somewhat complex and can be divided into 2 parts.
Let's look into the question first:
There are actually 2 possible reasons to change your codes.
Deprecation process for mysql extension.
Making your code safer against SQL injection.
For the first one, it is not actually an urgent reason.
It will be deprecated in the not-released-yet version and removed in not-even-known version. So, to hit whatever trouble you will need to have a PHP version with removed mysql support. According to my experience, new versions moves on the shared hosts slowly, and you have 7 to 10 years ahead.
For the second reason, simple bulk search and replace will do no good at all.
So, instead of going for this option in a hurry, I'd go for gradual refactoring, eventually replacing old code with better versions.

What is the role/responsibility of a 'shell'? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have been looking at the source code of the IronPython project and the Orchard CMS project. IronPython operates with a namespace called Microsoft.Scripting.Hosting.Shell (part of the DLR). The Orchard Project also operates with the concept of a 'shell' indirectly in various interfaces (IShellContainerFactory, IShellSettings).
None of the projects mentioned above have elaborate documentation, so picking up the meaning of a type (class etc.) from its name is pretty valuable if you are trying to figure out the overall application structure/architecture by reading the source code.
Now I am wondering: what do the authors of this source code have in mind when they refer to a 'shell'? When I hear the word 'shell', I think of something like a command line interpreter. This makes sense for IronPython, since it has an interactive interpreter. But to me, it doesn't make much sense with respect to a Web CMS.
What should I think of, when I encounter something called a 'shell'? What is, in general terms, the role and responsibility of a 'shell'? Can that question even be answered? Is the meaning of 'shell' subjective (making the term useless)?
Thanks.
In Orchard the term "shell" is really more of a metaphor for a scope. There are three nested scopes: host, shell, and work.
The host is a single container that lives for the duration of the web app domain.
The shell is a child container created by the host that is built according to the current configuration. If the configuration is changed a new shell is built up and the existing one is let go.
The work is another a container, created by the shell, that holds the components that live for the duration of a single request.
One nice thing about the use of a shell container it that it helps avoids the use of static variables and the need to cycle the app domain on when configuration changes. Another nice thing is that it enables an Orchard app domain to serve more than one "site" at the same time when the host holds a number of shells and uses the appropriate one for each request.
I think that a general meaning for shell would be 'user process that interprets and executes commands'.
'User process': as distinct from a process built into the operating system kernel. JCL in the IBM mainframe world would be hard-pressed to count as a shell.
'interprets and executes': in some shape or form, a shell reads commands from a file or a terminal, and reacts to what is presented, rather than being rigidly programmed to do a certain sequence of commands.
'commands: what the commands are depends on the context. In the standard Unix shells, the commands executed are mainly other programs, with the shell linking them together appropriately. Obviously, there are built-in commands, and also there is usually flow-control syntax to allow for appropriate reactions to the results of executing commands.
In other contexts, it is reasonable to think of other sorts of commands being executed. For example, one could envision an 'SQL Shell' which allowed the user to execute SQL statements while connected to a database.
A Python shell would support Pythonic notations and would execute Python-like statements, with a syntax closely related to the syntax of Python. A Perl Shell would support Perl-like notations and would execute Perl-like statements, ... And so the list goes on. (For example, Tcl has tclsh - the Tcl Shell.)