I am executing selenium test classes using testng and creating logs. In case of parallel execution of test classes using TestNG Factory, logs are getting mixed and bit confusing.Is there any way we can create logs in parallel test execution in order of execution of test classes and one class logs separate from other. Thanks !!
Are you using any logging framework for example: log4j and talking about separate that logs or talking about TestNG default logging? TestNG's default logging doesn't supports it.
TestNG has it's own custom logging framework similar. To control testNG logging you can add "log4testng.properties" to your classpath.
However as per documentation, there is no way to specify appenders or to control logging programmatically.
For logs which are not from TestNG you can use other logging framework than TestNG's default, like log4J. In that case refer similar question using-different-log-files-for-every-thread-created
Related
I have created a custom TestEngine using the JUnit 5 (junit-platform-engine) framework.
The custom TestEngine registers using the ServiceLoader mechanism with an entry in META-INF/services/org.junit.platform.engine.TestEngine.
When I run my tests, this works well, but the tests get run a second time by the built-in JUnitTestEngine.
Is it possible to replace the default TestEngine in this circumstance instead of supplement it?
After checking the JUnit 5 user guide and documentation for maven surefire plugin it seems there's currently no way to filter out certain test engine with Maven :-(.
Using the console launcher, however, does allow to choose test engines: https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher-options. And so does Gradle: https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle.
Was looking for a solution to run a feature file at the end of the suite
My workflow (In parallel Run)
karate.callSingle('Login.feature') so at the beginning i do one
login and then use the cookies/token for the whole suite
Run tests in Parallel
Runs the Logout.feature file
There is no direct support for this currently. By the way no one has ever requested this. If this is so important, kindly open a feature request.
One workaround is to set a singleton / Java static variable from callSingle and then in your JUnit / Java parallel runner, call the feature to logout using the Java API (search the docs for this) and you can pass arguments / access the static variable.
EDIT: just realized that the #AfterClass JUnit annotation may be more than sufficient for your needs.
I want to connect Jmeter to Redis DB, I want to do it via java programming.
I added jedis-2.2.1.jar file to lib folder.
and create a test plan with only bean-shell preprocessor.
I can not understand what I can see, since nothing happened, and the response tree is blank,
Can someone please advise how to connect to redis via jmeter (please without the redis plugin)
Provided the Pic of the program, it is a simple program just want to connect.
** I am new in java scripting in Jmeter and the only jar I added is jedis.jar, the program is a script from the net. not created thread group in the test plan
with void main it is not worked also
You need to add a Sampler to your Test Plan. PreProcessors are executed before samplers, single PreProcessor won't do any work as it will simply not be executed. So you either need to add a Sampler to your test plan or convert your PreProcessor to be a Sampler
Since JMeter 3.1 it is recommended to use JSR223 Elements and Groovy language for any form of scripting. The reasons are in:
Groovy performance is much better as it is capable of compiling scripts and caching them
Groovy fully supports Java syntax, valid Java code most likely will be valid Groovy code while with Beanshell you are stuck with Java 5 language level
Groovy provides many enhancements on top of Java SDK
See Apache Groovy - Why and How You Should Use It article for more information, benchmarks, examples of real-life Groovy usage, etc.
The solution is to use bean shell sampler and not pre-processor to see response.
Here is a JMeter file and beanShell Sampler script to fetch a set of keys from redis and put them into variables used by a looping HTTP GET request.
https://bitbucket.org/barryknapp/shared/src/d62f8ebb57ede1d15a3bd7683adfdd02cd039369/jmeter/?at=master
I'm trying to get tests results while the job is building.
When we run tests suite by eclipse we get tests results from TestNG viewer while running the suite, I want to get the same viewer or similar in Jenkins to know the current status of the build before finish.
I mean this in TestNG Viewer:
Results of running suite TestNG viewer
Thanks All :)
AFAIK it is not inbuilt as part of any plugin. But there are couple of options that you can try.
Write results to a database in the IInvokedMethodListener after implementation. Build a ui over the database.
Maintain a datastructure of results , do console out of summary(if you are the only one who needs to know the results) on jenkins in test listener or method listener of the results based on the frequency at which you need to know results. Or you can start of a parallel script which parses the consoleText either as a shell or a separate utility doing curl on the consoletext.
I have the following set-up: an integration tests project which has a suite of tests written in Groovy/Geb + Spock, which are running perfectly both using Selenium WebDriver and Selenium Grid (RemoteWebDriver).
The problem is that no matter how much I try to tweak the "system", I can't get the tests to run in parallel (i.e. although I have 3 slaves [nodes] registered to the hub, only one of the slaves actually receives the requests). I've enforced maxSession=1 to the Selenium nodes and tried different combinations of parallel=classes|methods, threadCount and fork settings in failsafe plugin configuration (pom.xml file).
I have the feeling that the problem lies somewhere between the maven configuration and selenium grid, probably in relation to Geb/Spock config.
Does any of you have any insight on this issue?
PS: someone suggested that running tests in parallel using Geb / Spock is not possible - because for some reason ?Geb? locks the JUnitRunner (not sure what this means).
Add following configuration to your build.gradle file:
tasks.withType(Test) {
maxParallelForks = 3 // here three forks shall open in parallel
forkEvery = 1
include '**/*TestName*.class' // name of your test class
}
There are test frameworks, TestNG for example, that support parallel testing on the method level out of the box.
Spock, as an example to the contrary, does not support it.
But you do not have to have multithreading implemented by your test framework to make this work.
You can use your build tool to run test classes in parallel, both Maven and Gradle support this.
If you are using Maven, this documentation page and examples might help you:
https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html
Specifically have a look at "Forked Test Execution".
You can run it for sure, The point is you have to put them (your tests) in threads. Here is the link.