Undefined step definition in cucumber java - selenium

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.

Related

JavaFX application fail to launch with native exe bundle created with intellij ide

I have build a JavaFX application which can be executed by its jar file. However if i try to run it using the native exe bundle i am receiving two popups:
Error Invoking method
Failed to launch JVM
and the application fails to start.
The Javafx application is build with intellij ide.
The project structure looks as follows;
when launching the application following popup shows..
The config file looks as follows:-
The packaged jar file is executing properly...
the problem occurs when starting application with launching exe file.
kindly tell me what could went wrong?
UPDATE:
It seems that the build output runtime/bin directory does not contain java.exe file therefore i think the application does not launches.
the output when try to run the application is as follows:
i have build the application with intellij idea, i think there is a problem with that. Kindly look into this matter.
UPDATED:-
Run it from the command line using the runtime that was bundled for you:
If you made an executable Jar (with a proper manifest specifying the classpath and main class)
cd firecap
runtime\bin\java -jar app\libs\your-main.jar
If you don't have an executable jar use something like
cd firecap
runtime\bin\java -cp app\libs\*.* your.main.class.name
Since java.exe is a console program you should be able to see the full error output to get a better idea of what is going wrong.
You very likely have missed including a needed module in the runtime.
It is also possible you ran into a bug that I discovered recently: https://bugs.openjdk.java.net/browse/JDK-8254920
I created my runtime image with this command:
"C:\Program Files\BellSoft\LibericaJDK-15-Full\bin\jlink.exe" --no-header-files --no-man-page, --compress=1 --add-modules java.management,java.logging,javafx.controls,java.xml,java.desktop --output C:\MyProject\build\image\runtime
But yours may be different depending on what modules you need. Note also that I used a JDK from BellSoft that included the JavaFX modules to make it easier.

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.

Purpose of Test scripts for Appveyor? Intergration with Codecov

We have started using Appveyor for CI with our Github repo and all has went fine. We have our build script working (appveyor.yml) in the repo, and it successfully builds and produces an artifact. Now on to my question
We are trying to pair our builds now with codecov.io which says it will scan it during the CI build. And it does support appveyor, it merely says to add this to the yml
after_test:
- bash <(curl -s https://codecov.io/bash)
Which we did, but nothing happens. Does this mean i need an actual test script to run, before it will send off the code to codecov? It is a C# project, and we have it compile, and generate the .exe which we then package into a zip which can be downloaded.
What are the point of these "test scripts" when we already know it compiles and produces an exe? I am a bit confused on how to use this properly..
I believe here https://github.com/codecov/example-csharp is good example of running codecov tests on C# project with working Appveyor configuration. Please look at readme.md file in that repo for greater detail.
From the Documentation
You need to add the OpenCover nuget package to your Visual Studio solution which is used to generate code coverage analysis:
PM> Install-Package OpenCover
Secondly, you need to either write a PowerShell script (if you intend to generate code coverage and upload the result interactively) or you need to add a few entries in you CI config file (if you intend to let your CI generate the coverage).

PhantomJS teamcity config

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.

Getting error Could not find or load main class org.testng.TestNG

I'm trying to run TestNG from command line, but it's giving me error.
Can someone tell me where am I going wrong?
java -cp C:/TestNG directory/testng-6.2.jar;C:\project directory\src\com\suites\suite\shop org.testng.TestNG testng.xml
Error: Could not find or load main class org.testng.TestNG
My scripts runs fine when I ran them from eclipse testng plugin.
Copy the below commands in a text file.
Edit the location.
Save it as yourtext.bat
Now, double click on the batch file created.
cd C:\Workspace\projectname
java -cp C:\Workspace\projectname\lib*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml
Path of TestNG.jar file was not set up.
Follow instructions of following site to set up. It worked for me:
http://qtp-automate.blogspot.com/2011/10/running-selenium-testng-test-from.html
Try above answers.
If still not work, then you might have downloaded the wrong version of testng.jar. From link testng.org, please click "here for ant users" to download a full testng.jar(11 mega bytes), not a "Maven Central" version(no more than 100k).
I have tested those two versions on centos following testng tutorial point
Possibly your testng.jar file is not in the lib folder that C:\Workspace\projectname\lib.
You should find testng.jar first in your computer and move it manually to C:\Workspace\projectname\lib. Then it will work
Check that the lib folder contains testng-6.8.jar(or any other version) file because testng.xml even executes successfully without testng-6.8.jar (or any other version) with the jars that gets added when we add TestNG library.
My Assumptions:
You are trying to run test file from command prompt
libs folder generated under Project/tagret upon using "mvn clean package -DskipTests"
class file generated under Project/target/test-classes/package-name
With above assumptions in mind, you can follow below process.
Setting class path in command prompt:
1. Open project location in command prompt
2. set classpath=C:\User\SeleniumTestProject\target\test-classes;C:\User\SeleniumTestProject\target\libs\*
3. java org.testng.TestNG C:\User\SeleniumTestProject\testng.xml