I had a situation where i am working in home.feature and need to call return.feature and gets the data. And internally return.feature is calling data.feature and collects all the data from it.
Source
directory1
home.feature
directory2
return.feature
data.feature
I have written * def response = call read('classpath:source/directory2/return.feature') in home.feature.
while calling this line, it is picking up the correct feature file, but while executing return.feature, it throws error while calling data.feature(javascript evaluation failed. java.io.FileNotFoundException).
Please guide what could i do in home.feature file, as i dont have access to change in directory2.
Thanks in advance
There is a this: prefix: https://github.com/intuit/karate#reading-files
So this should work when you are inside return.feature
* call read('this:data.feature')
Related
I know it is possible to delete the entire Jmeter result tree, through the code:
import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.JMeterGUIComponent;
import org.apache.jmeter.gui.tree.JMeterTreeNode;
import org.apache.jmeter.samplers.Clearable;
log.info("Clearing All ...");
guiPackage = GuiPackage.getInstance();
guiPackage.getMainFrame().clearData();
for (JMeterTreeNode node : guiPackage.getTreeModel().getNodesOfType(Clearable.class)) {
JMeterGUIComponent guiComp = guiPackage.getGui(node.getTestElement());
if (guiComp instanceof Clearable){
Clearable item = (Clearable) guiComp;
try {
item.clearData();
} catch (Exception ex) {
log.error("Can't clear: "+node+" "+guiComp, ex);
}
}
}
but I didn't want to delete the entire result tree, only the returns that returned with status == 500. Because my api returns 500 until the callback is available for consultation, when it finds the callback it returns "success", so while the api keeps retrying, these retries show up as an error in the report,but in fact the callback has not returned yet, when it returns the api returns the callback and is successful. I would like to remove these requests from the report, which are retry.
Add a JSR223 Post Processor with following code to ignore the test results when the response code is 500
if (prev.getResponseCode()=="500"){
prev.setIgnore()
}
prev - (SampleResult) - gives access to the previous SampleResult (if any)
API documentation for prev variable (SampleResult)
I don't think it's possible without modifying JMeter source code or heavily using reflection. In any case the answer will not fit here.
In general:
You should be using JMeter GUI only for tests development and debugging, when it comes to test execution you should run your test in command-line non-GUI mode
You should not be using listeners during test execution as they don't add any value, just consume valuable resources, all the necessary information is stored in .jtl results file
There is Filter Results plugin which allows removing the "unwanted" data from the .jtl results file
You can also (as well) generate the HTML Reporting Dashboard out of the .jtl results file, the Dashboard has its own responses filtering facilities
guys. First, thanks for the answers, I ended up giving up on the idea of removing the result from the tree and looking for a way to modify the way that result is presented.
I made a beanShell assertion, so that if Status==500, it would return "Success" in the result tree:
BeanShell
I also made it so that if it were a new attempt the name displayed in the results tree would indicate this, leaving the api name mutable depending on the return:
api name = variable
and I have this logic:
import org.apache.jmeter.samplers.SampleResult;
//process main sample
if (${status} == 500) {
SampleResult.setResponseCodeOK();
SampleResult.setSuccessful(true);
vars.put("Api_Fake_Client_name", "API_FAKE_CLIENT_RETRY");
I will configure the answers in the other conditions, but I believe that this way I will be able to solve my problem because the new attempts no longer appear as an error.
I just started learning about groovy and trying to transpose my java code to groovy scripts. Usually java allows you have a class with only methods that you can call from other classes. I wanted to translate that to groovy. I have in one file - lets call it File1- a method like this:
def retrieveData(String name){
// do something
}
and in the second file, File2, I call File1 like this:
def file1Class = this.class.classLoader.parseClass(new File("../File1.groovy"))
and then try to call the method in File1 like this:
def data = file1Class.retrieveData("String")
but it keeps giving me this error - MissingMethodException:
groovy.lang.MissingMethodException: No signature of method: static File1.retrieveData() is applicable for argument types: (java.lang.String) values: [String] Possible solutions: retrieveData(java.lang.String)
so it does recognize that I am sending in the correct number of parameters and even the correct object, but it isn't running the method as it should?
Is there something I am missing? I tried to remove the object definition from the method - in other words - like this:
def retrieveData(name){
// do something
}
but that didn't work either. I am clueless about what the next step would be. Can anyone please help push me in the right direction? I would greatly appreciate it.
See the answer provided in this StackOverflow reponse.
Use the GroovyScriptEngine class. What does the GroovyScriptEngine do? From the docs:
Specific script engine able to reload modified scripts as well as
dealing properly with dependent scripts.
See the example below.
def script = new GroovyScriptEngine( '.' ).with {
loadScriptByName( '..\File1.groovy' )
}
this.metaClass.mixin script
retrieveData()
Note how we use the loadScriptByNamemethod to
Get the class of the scriptName in question, so that you can
instantiate Groovy objects with caching and reloading.
This will allow you to access Groovy objects from files however you please.
I've build a method which takes strings as input parameter. In my index.jsp page, I retrieve a GET-variable from the URL using request.getParameter(). Now, I want to call the aforementioned method on this string, but I get a compiler error saying:
The method <method name>(String) is undefined for the type __2F_<webapp name>_2F_src_2F_main_2F_webapp_2F_index_2E_jsp".
Does anyone know why I get this error and how I can get rid of it. Any help is greatly appreciated!
My code is rather lengthy, but I think this is relevant code:
categorie = request.getParameter("categorie");
if (categorie.equals("")) {
categorie = "Category;";
}
ArrayList<String> categorieen = queryCategories(categorie);
You are calling ArrayList<String> categorieen = queryCategories(categorie); and you did not define queryCategories method. Since the JSP page is compiled into a big servlet class, it tries to locate queryCategories method as member of that class and it could not find it.
Very little information. Where is your app deployed? From what I gather, it seems you either haven't restarted the deployed app or have not replaced the changed class file and haven't set some sort of "development mode" on wherein you don't require a restart for a Jsp modification.
Just replace the .jsp and JSP_NAME.class file.
I've create an app using the Playfrawork with Java.
And I'm using the SecureSocial plugin on it.
Inside my controller there is a method that one of the process of it is to execute the handle start reset password inside the SecureSocial.
But that method is written in Scala.
If I refer the method inside my Java source like this:
Registration.handleStartResetPassword();
Nothing happens! Same if I change to the following line:
Registration.handleStartResetPassword().apply();
Same as the following source code block:
play.api.libs.iteratee.Iteratee<byte[], SimpleResult> it = Registration.handleStartResetPassword().apply(ctx()._requestHeader());
Future<SimpleResult> future = it.run();
Option<Try<SimpleResult>> result = future.value();
SimpleResult res = result.get().get();
I removed all my code and just tried to execute the Secure Social code but nothing happens.
Here is my method:
public static Result resetPassword() {
Registration.handleStartResetPassword().apply();
return TODO;
}
My route is this one:
POST /reset controllers.ProfileController.resetPassword
Edited: Added another way that I've tried to run but just didm't got the method running.
When you call handleStartResetPassword() you get an instance of Action back, it doesn't actually do anything until you to feed it with a particular request by calling Action.apply(request) which will then actually run the logic for that controller action and return a Future<Result>.
Not entirely sure if you can bridge backwards and get a play Java async result out of that though.
I got an XLS pic inside of an HTML link, and i need to verify some information first before calling to the servlet, that's why i'm not including the servlet inside of the href="". So i've created a javascript function that verifies the input information in order to be used by the servlet.
(The Servlet returns a XLS in order to be saved by the user).
Tried this:
document.location.href = 'saveExcelServlet.do?' + <<GET method attributes>>;
But it didn't work.
It says:
Problem accessing /wscall-metrics-web/saveExcelServlet.do. Reason:
null
Caused by:
java.lang.NumberFormatException: null
If i write it works...
Can anyone help me?
Thanks.
M.
There's a good chance the URL isn't quite built the way you expect. A great poorman's technique for debugging this kind of thing is to assign a variable and pop it up in an alert:
var newLoc = 'saveExcelServlet.do?' + <<GET method attributes>>;
alert(newLoc);
You can see exactly what URL is getting fetched.