PhantomJS teamcity config - testing

In a teamcity config I have build step which runs PhantomJS tests. It is a "Command Line" step with custom script. The script looks like:
%PhantomJS% CreateEntityPopupTest\unit.htm
%PhantomJS% ExcelImportPopupTest\unit.htm
...
etc.
So it runs each qunit test package mentioned in the htm page. But I didn't manage to find a way to point PhantomJS (phantomjs-1.9.0-windows) to a folder, not to a single file. So there would be no need to change the config each time when we add new files with tests.

I used Chutzpah to wrap this behavior for use in TeamCity. Chutzpah can run tests written in QUnit, Jasmine or Mocha and uses PhantomJS as the headless test runner.
https://github.com/mmanela/chutzpah
I installed it on the build agents and added it to the path on the machine.
Now I simply add a Command line runner step called 'Run JS Test' in my build template. Command line is simply:
chutzpah.console.exe %jsTestFolder%
Then I just define the parameter for each project pointing to a folder... chutzpah does the rest.

Related

WebStorm/Intellij Gherkin tests configuration run

How to set up running configuration with WebStorm feature file?
When I click on green run button seems that WebStorm can't find the steps realisation.
How could I change that WebStorm understands from where should it take steps?
When I run tests with command line it works, I have config file where I declared steps folder.
You can specify --require path/to/step/definitions as Cucumber.js arguments: field:

Run CMD/Powershell command before the build command?

How I can run a CMD/Powershell before my Java GUI Application will be build and invoked.
I want run the command: sass ANYFILE.scss:ANYFILE.css to compile my scss file first.
In the Run/Debug Configurations I found nothing which helps me at the Before launch option.
Add the External Tool in IDE which will run any command you want, then add it in Before launch section.
There is a PowerShell plugin that provides a run configuration to run powershell scripts. You can add it as Before launch option as well.

Why karate runner file is not run before running the feature files, when running Junit4 Test.java file for tests

Karate suggests that to run all tests in a CI environment, a *Test.java file should be added above the feature files (in hierarchy) and then run using - mvn test command.
I am using my Runner.java file to create test data before the tests are run and then do a clean up. I run this runner file in IDE and everything runs fine - the data is created, all feature files in the same package run and then clean-up is performed. The reason i used the Runner file to create data is because i using karate itself to create test data and the Runner file passes some information on created data to the feature files to run api tests. I had earlier posted a question regarding how to achieve this, please refer to this answer - https://stackoverflow.com/a/55931786/4741035
So now I have a *Test.java file in my project which i run using - mvn test. This runs all the feature files and tests fails as the Runner.java is not executed at all.
Why doesn't karate run the Runner file, if it is present first that the feature files?
Help is much appreciated.
If you are trying to run something "once" before all your tests, use karate.callSingle() documented here: https://github.com/intuit/karate#hooks
var result = karate.callSingle('classpath:demo/headers/common-noheaders.feature', config);
And in the above feature (or JS) you can call Java code using Java interop.
By the way I don't agree with the answer you linked because of the above approaches.

How do I make IntelliJ create Mocha debug configs when running unit tests?

When I create a new Mocha test file I am presented with the expected green gutter icons (▶ and ▶▶) to run each test or the suite. When I select "Run [test name]" I expect it to create a Mocha debug configuration and run it. Instead, IntelliJ creates a NodeJS run configuration, which understandably explodes in a shower of bit-flavored WTF.
If I manually create a configuration for the whole file, everything works as expected, including individual tests afterward. I am hoping that there is a setting somewhere that I have overlooked, something like "Settings -> ... -> Default Debug Configuration".
Does anyone know how I can make IntelliJ default to Mocha when a unit test is executed?
The logic used for determining what test runner is available for a given test file is based on dependencies declarations in package.json nearest to current file. Do you have 'mocha' listed as a dependency/dev dependency in your package.json? How many package.json files do you have in your project?
Note that, if Mocha is not installed locally/included in package.json, you can create a Mocha run configuration with "All in directory" selected and specify a directory where your spec files are located. In this case, clicking the gutter button in a test file inside this directory will suggest to run test with Mocha.
Note also that if you have created Node.js Run configuration with "JavaScript file" set to your mocha test file, IDEA will suggest using this configuration instead of Mocha when clicking on your tests, because explicitly created run configurations associated with current file have priority over the ones auto-generated from context. Deleting the configuration should solve the issue.

Undefined step definition in cucumber java

I have written a scenario to login to the application using cucumber framework. Initially I had written the code in eclipse and It run successfully, but when I copied the same code and dependencies the code is not at all working it is saying that the step is undefined.
That shouldn't be an issue. Are you executing the tests from the root dir. what was the command your using to run the tests. mostly the directory path would be the issue. check and try the relative path to avoid such issues.