How to run specific 'it' blocks in protractor - jasmine

Created a spec file with combination of test cases ('it' blocks), the definition will be as below:
spec1.js
describe('suite', function(){
it('test case1', function()
{
//test case definition
})
it('test case2', function()
{
//test case definition
})
})
conf.js setup is as below.
suites: {
suite1: [
path.resolve(filePath.specFile1),
path.resolve(filePath.specFile2),
path.resolve(filePath.specFile3)
]
suite2:
[
path.resolve(filePath.specFile1),
path.resolve(filePath.specFile3)
]
}
The commands to trigger in package.json as
"suite1test": "protractor ./conf.js --suite suite1",
"allTest" : "protractor ./conf.js"
from the command line, we can trigger suite1 as "npm run suite1test"
But my requirement is, I want to execute 'test case1' 'it' block only from spec1.js like that specific test cases from the spec files and make a group as a test suite.
When I search for the solution, I got it that we can disable some test case or suite by preceding with 'x' i.e., 'xdescribe' disables that suite and 'xit' will disable particular 'it' block
If want to execute a particular test suite or test case then we can be preceding with 'f' focus i.e., 'fdescribe' will execute that suite and 'fit' will execute that particular 'it' block.
This is a lengthy process if want to create a separate set of a test suite or test cases that want to execute, each and every time, we need to change on each spec file level. Instead of this, want to trigger from the conf.js by creating separate suites pointing to particular 'it' blocks and trigger when it required.
Is there any solution for these?

You need separate spec files and then you can call them in spec from conf.js.
It is not good practice to add x or f and change it all the time.

Related

rspec command to run tags with specific tag values

I have ruby spec files where each test cases are tagged with testId tags. My requirement is to run the test cases using zsh command where I have to run only specific test case ids (testID tag).
I could see "-t testID:1234" would run only test cases with testID=1234.
I have an array of test case ids and I need to run only those test cases.
Is there any way to attain this requirement using rspec tagging?

cypress-testrail-reporter creates separate runs for each of my test files in TestRail instead of one test run

I currently have 2 test files that get ran on every build. It seems that for each test file, it creates its own test run in TestRail. So it reports a test run with 4 test cases and another test run with 7 test cases.
What I need and what used to happen before is to have only 1 test run with all 11 cases reported to TestRail.
Here is my cypress.json
"reporterOptions": {
"host": "https://yourdomain.testrail.com/",
"username": "email",
"password": "CYPRESS_TESTRAIL_REPORTER_PASSWORD",
"projectId": 32,
"suiteId": 103769,
"runName":"Cypress Automated Test Run"
During the build, I can see that after each test file it prints out
- Test run closed successfully
This did not happen before. Is there anything that changed, or what do I need to do to get only 1 test run.
There's an option includeAllInTestRun: true, or make sure that the case codes in the test title are actually in the same project/suite.
it("C123 C124 Can authenticate a valid user", ...
it("Can authenticate a valid user C321", ...
Case IDs are extracted as any separate word starting "T" or "C" followed by digits,
let testCaseIdRegExp: RegExp = /\bT?C(\d+)\b/g;
You can use
npm install cypress-testrail-accumulative-reporter
It will create a test run that contains all of your test cases

How to automatically running multiple load tests in SOAP UI free version?

I have two load tests below with each one being in their separate test cases. This is using SOAP UI free:
Currently I have to manually select a load test, run it manually, wait until it finishes and then manually export the results before manually moving onto the next load test and performing the same actions.
Is there a way (and if so how) to be able to automatically run all the load tests (one by one) and extract each of it's own set of results in a file (test step, min, max avg, etc). This is to save the tester having to do manual intervention and can just let the test run whilst they do other stuff.
You can use the load tests command line, the doc is here.
Something like
loadtestrunner -ehttp://localhost:8080/services/MyService c:\projects\my-soapui-project.xml -r -f folder_name
Using these two options:
r : Turns on exporting of a LoadTest statistics summary report
f : Specifies the root folder to which test results should be exported
Then file like LoadTest_1-statistics.txt will be in your specified folder with csv statistics results.
inspired with answer of #aristotll )
loadtestrunner.bat runs the following class : com.eviware.soapui.tools.SoapUITestCaseRunner
from groovy you can call the same like this:
com.eviware.soapui.tools.SoapUITestCaseRunner.main([
"-ehttp://localhost:8080/services/MyService",
"c:\projects\my-soapui-project.xml",
"-r",
"-f",
"folder_name"
])
but the method main calls System.exit()...
and soapui will exit in this case.
so let's go deeper:
def res = new com.eviware.soapui.tools.SoapUITestCaseRunner().runFromCommandLine([
"-ehttp://localhost:8080/services/MyService",
"c:\projects\my-soapui-project.xml",
"-r",
"-f",
"folder_name"
])
assert res == 0 : "SoapUITestCaseRunner failed with code $res"
PS: did not tested - just an idea

How can I run a specific 'thread group' in a JMeter 'test plan' from the command line?

How can I run a specific thread group in a Test Plan from the command line? I have a Test Plan (project file) that contains two "thread groups": one for crawling a site and another for calling specific urls with parameters. From the command line I execute with Maven, like so:
mvn.bat -Dnamescsv=src/test/resources/RandomLastNames.csv
-Ddomainhost=stgweb.domain.com -Dcrawlerthreads=2 -Dcrawlerloopcount=10 -Dsearchthreads=5 -Dsearchloopcount=5 -Dresultscsv=JmeterResults.csv clean test verify
I want to pass an argument to run only one of the two "thread group" in that project file. Can you do that with JMeter? I don't want to use an IF controller unless I have to because it feels like a "hack". I know that SoapUI lets you do this with the '-s' option.
I asked this question on the JMeter forum also.
In our tests we use the while controller. It doesn't look like a hack to me and works well. You can turn thread groups on and off easily with the JMeter properties. Note you can't change its status when the test is already running though.
Add While controller - ${__P(threadActive)}
Set JMeter property on JMeter load ( -JthreadActive = true )
Run test
Please note ${__P(threadActive)} equates to ${__P(threadActive)} == true, anything other than true will result in that thread group not running

How to see what Protractor tests is currently executing?

In my Protractor test script, I use the usual notation:
describe("mytest") {
...
it(" should do this") {
...
it(" should do that") {
I would like to be able to see what test and what part of each is currently running when I run them. Is there any option I can use to output test descriptions to the console?
There is a reporter that should do what you are looking for. Take a look at https://www.npmjs.com/package/jasmine-spec-reporter and https://github.com/bcaudan/jasmine-spec-reporter/tree/master/examples/protractor
You can use the --verbose option to print more information about your tests, but it will not tell you which test is currently being run.
I suggest you to create an issue if you want that feature. https://github.com/angular/protractor/issues/new
$ ./node_modules/protractor/bin/protractor protractor-config.js --verbose
------------------------------------
PID: 7985 (capability: chrome #1)
------------------------------------
Using the selenium server at http://localhost:4444/wd/hub
angularjs homepage
should greet the named user
todo list
should list todos
should add a todo
Finished in 5.915 seconds
3 tests, 5 assertions, 0 failures
since protractor runs in node you can use console.log as you normally would in javascript, for more console fun see the node docs
I like to place any logs after functionality so that I know its been completed, so wrapping it inside of a .then() function seemed to work best for me
example:
element(elementToFind).click().then(function(){
console.log("clicked element");
continue();
});
If you need to know the name of the spec currently rinning you could use: jasmine.getEnv().currentSpec.description
and log it
console.log('\nTest spec: ' + __filename + '\n');
to log the test but no idea how to log the it being executed

Resources