Executing Karate scenarios calling external JAR from VScode - visual-studio-code

I use Karate as standalone JAR, and for writing scenarios I've installed Visual Source Code with the "karate-runner" plugin as IDE support.
I use an external jar for encryption treatments.
The trouble is that, when I execute a Karate scenario from Visual Source Code (for debuggig purpose), my external jar is not taken into account, and during execution, I get the message "java.lang.ClassNotFoundException: GenerateSign" in the console.
I've no problem when I launch the scenario directly in command line like :
Karate.bat mytest.feature
With the content of karate.bat is :
java -cp karate.jar;Sign.jar;. com.intuit.karate.Main %*
So, how to configure the tools in order to execute my karate scenarios from VScode taking into account my external jar too?
Thanks a lot.

I suspect the problem is you haven't updated the "karateCli" property in your launch.json debug configuration. Can you try to update it including your additional jar file and try again.
EDIT
Based on what command line does work in your batch file you should update your "Karate Runner" extensions settings as shown below in the images.
For running tests from Codelens with "Run Karate Test(s)"
For running tests with VSCode debugger

Maybe you simply are on the wrong version. Dir you try 0.9.5 ?
Here are the instructions: https://marketplace.visualstudio.com/items?itemName=kirkslota.karate-runner
For those coming across this in the future, you can use this as an additional reference: https://github.com/intuit/karate/wiki/Karate-Robot-Windows-Install-Guide

Related

Debugging a software verifier written in sbt on Intellij Idea

I'm working with Stainless, a software verifier for Scala programs. I would like to debug the verification process of a sample programme on Intellij Idea. On a previous post, I solved this integration problem for an interactive theorem prover. But now, I'm facing two problems:
Apparently, the verification software runs at compile time. That is, I enter in the sbt console and run the compile command and then the verification process seems to be done. You may try this with this verified example. This situation is new to me, since I was used to debug the program while executing.
All the setup in the sbt files of the example above (see for instance this file) seem to refer to online content, while I want to make sure that I work with my local copy forked from the original repository of the verifier.
None of the configurations I tried worked. Can you help me out of this problem?
Details
This is the current configuration page of stainless.
If the verification runs within the sbt process, you can debug it by attaching the debugger to sbt. IntelliJ makes this easy with the embedded sbt shell:
open the sbt shell toolwindow
click the "attach debugger to sbt shell" button on the left
set breakpoints in your code
run the task

Testng - Ant - windows terminal how to deal with errant input

I have a java selenium QA project where we use ant and testng via the powershell terminal. What I would like help with is creating a redirect if a tester enters a typo in the terminal.
If I am in the run directory and I simply type ant, it will run the default.xml file listed in the build.xml file which is what I expect.
If I enter an actual ant command with a typo though:
ant -Dtestdir= c:\dev\qa\src\tests -Dtestxml=blablabla
it will attempt to run every test.xml file in the test directory. This is especially problematic because most of the those test.xml files call java classes that contain #Factory and #Dataprovider(s) and they allocate everything at once which just causes everything to fail.
What I would like is a way to tell ant if the input is erroneous, then run the default.xml file(which I have configured to populate an html error page). I've been reviewing both testng and ant docs and I'm not finding a solution, so your guidance would be appreciated.
Other than this one issue, the system works very well.
After digging around a bit more and learning how to ask the question properly, I found 2 great examples here on SO.
1) Create an additional ant target that checks for the existence of the file the user has typed. And add it to the depends attribute of the main target , and also adding the if attribute.
Example
2) Use the Ant fail task and fail the build (with a message) if the file is not available. I prefer this one because the tester can get some feedback.
Example 2

how to include run as configurations in exported eclipse product

I am exporting eclipse rcp application using "eclipse product export wizard". I want to redirect console logs into a file.
I am doing the below, which is working fine when I run as a eclipse application. It is not reflecting after export.
The Run configurations cover how to run something, i.e. they are the part external(ish)* to your application.
In particular, the Output File and Standard Input and Output settings are ways in the Eclipse development environment to handle redirects of the application.
A quick rundown would be to run the console application like this:
$ path/to/app -application com.example.yourname > file.log
If the shell you are using is Bash, there is a long bit in the manual with further options. Powershell and cmd on windows have similar options.
Of course, if you want your program to write to a file all the time (with a possible command line argument to specify file), you probably will want to code that yourself.
* The reason I put "ish" on external is that some of the settings, like Configuration and Plug-ins are part of what you export, but Arguments, Tracing and Environment are not.

Getting Error : There is no simulation script. Please check that your scripts are in user-files/ simulations Press any key to continue . .

I am facing this problem, when executing gatling batch file using command prompt.
GATLING_HOME is set to "G:\gatling-charts-highcharts-bundle-2.1.4"
There is no simulation script. Please check that your scripts are in user-files/
simulations
Press any key to continue . . .
I have downloaded new Gatling copy gatling-charts-highcharts-bundle-2.1.4 from http://gatling.io/download/
And trying to run computerdatabase Simulation, getting error message.
Is there any way to run simulation other than using batch file through Command prompt?
Thanks
You can run it with
The sbt plugin
The maven plugin
As standalone application. You find an example in the Maven archetype
Run with Jenkins and the Gatling-Jenkins plugin
Note that the above documentation links use the Gatling version 2.1.7. Yet the plugins exist as well in older versions (like 2.1.4) and will probably continue in later versions as well - just replace the version number on http://gatling.io/docs/2.1.7/.
The cause may be the lack of JAVA_HOME environment variable.

deploying a scala app built using IDEA

I developed a simple scala app that uses casbah to query the DB for the command line argument passed to it. For example
$ querydb.scala execution 10
it will run a casbah query to find 10 records matching execution in mongo. Now i have two questions.
1) How do i test this in my local. If i click execute in intellij it is just running the program, i am not able to pass command line arguments to my program.
2) How do i deploy it to run on my server, it is just going to used as console app in my ubuntu server, but im not sure how i should deploy this, which files i should put up on the server and how do i execute it in server, and stuff like that.
Any pointers would be useful for me.
or try to use sbt, IDEA has a plugin with sbt, the wiki of it has an explanation on how to use it.
I usually use sbt directly in Terminal instead of running in IDE.
1) First you need to find "Select Run/Debug Configuration" button at the top of your screen
Click on it and choose edit
Create new one, if you haven't got it yet.
Your program parameters should be written in "Program parameters" field
2) Compile your .scala files with scalac and you'll got .class files.
Then deploy it, as you usually do with java code. Hence you don't need to install scala on target machine - all you need is JDK.