Using extentreports for jmeter test results - jmeter

As anyone who uses jmeter for api functional testing, the reporting is, eh, not that great. Has anyone used something like http://extentreports.com/ for displaying their test results? Any ideas on other ways to display test results better? In trying to use a tool that was mainly focused on performance testing and those test results, that does not work as well for when we are testing REST API calls and those results. For example, it would be nice to be able to capture data that is getting created during the test runs but, none of the reports that are built into jmeter do this. Any advice is appreciated.

Looking into Extent - Report API it should be possible to integrate it with JMeter, see How to Write a plugin for JMeter guide to get started
You can generate an HTML Reporting Dashboard at the end of your test run, it is not that bad.
You can use Backend Listener to store JMeter test results somewhere and visualise them in the most suitable for your form. See Real-time results JMeter User Manual chapter for more details.
And last but not least you can use 3rd-party analysis services like JAnalyzer or BM.Sense

I was able to use extentreports 2.41.1 and posted this code into a JSR223 PreProcessor. This seems to be the wrong element to put this in because I need results for each endpoint to show up in the report. This only just shows the script ran. Anyway, sharing in hopes it helps others
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
ExtentReports report;
ExtentTest testLogger;
String resultsPath = "C:/portalQA/Automation/Results";
String configPath = "C:/jmeter/apache-jmeter-3.2/lib";
String reportPath;
reportPath = resultsPath+"/test2/testing_extRpts_${myTimeinMills}.html";
report = new ExtentReports(reportPath, true);
report.loadConfig( new File(configPath+"extent-config.xml"));
testLogger = report.startTest("Entire Script");
testLogger.log(LogStatus.INFO, "This is the API test script for Login");
report.flush();
//Thread.sleep(2000);
//report.close();

Related

Jmeter - Functional Extent Report

I would like to use Extent Report in Jmeter for functional testing. Please suggest some sample script and language, library to do this. I explored our page and unable to get the lib and steps to implement them.
I followed the Using extentreports for jmeter test results
However, I am getting error message
Typed variable declaration : Class: ExtentReports not found in namespace
I am using extentreports-3.1.2.jar and kept inside the Jmeter Lib folder. Also I have imported them in the script as well.
Have you tried to look at Extents reports documentation? It seems to be comprehensive enough.
I don't know what you mean by "use Extent Report in Jmeter for functional testing", but given you're asking for a sampler code here is a minimal snippet suitable for using in any JSR223 Test Element assuming Groovy as the language:
import com.aventstack.extentreports.ExtentReports
import com.aventstack.extentreports.Status
import com.aventstack.extentreports.reporter.ExtentSparkReporter
import com.aventstack.extentreports.reporter.configuration.ViewStyle
def extentReports = new ExtentReports()
def reporter = new ExtentSparkReporter("report", ViewStyle.SPA)
extentReports.attachReporter(reporter)
def firstTest = extentReports.createTest("SomeTest")
firstTest.log(Status.PASS, 'Everything ok')
extentReports.flush()
You will need to:
Have extentreports-4.1.7.jar in JMeter Classpath (as well as all it's dependencies if you will be using MongoDB as the reporting backend)
Restart JMeter to pick the .jar up

How to properly import the MetricsServiceV2Client attribute from google.cloud.logging_v2 package?

I am trying to set up a locust based framework for ML load test and need to create custom metrics and logs for which the example that I am following is using 'MetricsServiceV2Client' in 'google.cloud.logging_v2' lib.
In the Vertex Workbench on GCP inspite being on v3.0 of the google-cloud-logging lib I am getting an issue of import
from google.cloud import logging_v2
from google.cloud.logging_v2 import MetricsServiceV2Client
error: cannot import name 'MetricsServiceV2Client' from 'google.cloud.logging_v2' (/opt/conda/lib/python3.7/site-packages/google/cloud/logging_v2/__init__.py)
Interestingly when I test the import in Google's cloud console I am able to import without any issue. What could be the issue?
Change it to the following:
from google.cloud.logging_v2.services.metrics_service_v2 import MetricsServiceV2Client
This will work.

Why are the java.net package not accessible in the BeanShell Sampler in JMeter

Initially all the imports were working fine until I closed and re-opened the script after which the color of few import statement has changed and are giving error when running the script.
See above, the some classes are showing black and some in golden. The ones in black are giving the beanshell exception.
It was working but suddenly after closing and re-opening the script has created this chaos.
Can someone explain this weird behaviour...?
As per Beanshell User Manual
Default Imports
By default, common Java core and extension packages are imported for you. They
are, in the order in which they are imported:
javax.swing.event
javax.swing
java.awt.event
java.awt
java.net
java.util
java.io
java.lang
Two BeanShell package classes are also imported by default:
bsh.EvalError
bsh.Interpreter
So basically you don't need to import these "in black" packages.
It is also possible to use "super import" to load the entire classpath like:
import *;
In order to get to the bottom of your script failure either add debug() directive to the beginning of your script - this way you will get comprehensive debugging information in stdout or put your code inside the try block like:
try {
//your code here
}
catch (Exception ex) {
log.error("Beanshell failure", ex);
}
This way you will get "normal" stacktrace in jmeter.log file.
See How to Use BeanShell: JMeter's Favorite Built-in Component article for more details.
Also be aware that since JMeter 3.1 it is recommended to use JSR223 Test Elements and Groovy language for scripting so I would recommend considering moving to Groovy, it is more Java compliant, has nice SDK enhancements and its performance is much higher.

No More Import Button on Parse

I no longer see the import button on Parse to import a JSON or CSV file. Did they move it somewhere or is it no longer possible to import those file types?
the official reason is this:
"[The import class button] was removed a couple of days ago due to an app that was abusing it and affecting people that had not migrated out yet. Now that the database is running on your own infra, you can simply importing directly to mongo so this shouldn’t be blocking you."
I hope this helps (to answer the question, not to import your class of course).
Cheers,

How to import data to sonarqube database?

I have my own report in a custom format and I want to import it somehow to sonar database to use sonar's widgets to show it. Is it possible in general? Is there any tools to do it?
This will require a custom plugin. Not knowing what type of data you're dealing with, I'll guess that the Generic Test Coverage plugin might be a good model.
You shoud try to do it using the webservice api. That's the recommanded way to do it.
The supported api is self documented on your SQ instance. Here is the API of the nemo instance : http://nemo.sonarqube.org/api_documentation

Resources