How to integrate the Reporter.log("Login failed.") with custom testng report using the IReporter? - selenium-webdriver

I have been trying to generate a custom testng report similar to the emailable-report.html which is generated by default in testng. In my test case, I have added reporter.log statement to check the flow of test execution, but these logs are not getting printed in the custom report.
Is there a way to integrate the log statement in the custom report ?

In order for the messages logged via Reporter.log() to show up in your test reports, you would basically need to retrieve them using Reporter.getOutput(result) (Here result is of type org.testng.ITestResult). Invoking this method you would get a list of strings which represents the output associated with that particular ITestResult object. You would need to dump these lines into your report.
For a sample, take a look at this section of the EmailableReporter2.java from TestNG.

Related

Salesforce developer console - APEX runner

I am trying to run code in the developer console. From the "execute anonymous window". How do i access the case written in the console from the child window.
it shows the attached error when trying to execute
I am still getting the same error. screenshot below. Please let me know if the screenshots are visible otherwise i will upload somewhere else.
"Test" is a name of a built-in apex class used when writing unit tests. It's bad idea to name your own classes like the standard ones, it can lead to "fun" scenarios like "integer account = 5; sobject a = new account();"
https://developer.salesforce.com/docs/atlas.en-us.234.0.apexref.meta/apexref/apex_methods_system_test.htm
Make new class with similar body, delete that one and try your code again.
And since your method is static, you can do MyClass.myTest(), you don't need "new"

Using the Python API is there anyway to get the Test Run's Status?

I currently have a python program which exports Test Runs, Test Plans, and Test Cases to CSV.
I am using the TestRun Model but I cannot get the information highlighted in the status column seen here. Is there anyway to get this information?
Thanks!
I currently have a python program which exports Test Runs, Test Plans, and Test Cases to CSV.
This is great. Please consider contributing your script under https://github.com/kiwitcms/api-scripts
I am using the TestRun Model but I cannot get the information highlighted in the status column seen here. Is there anyway to get this information?
Note: these screenshots are old!
There is no TestRun.status field, the status is only a visual property which is calculated by the UI based on the presence or absence of TestRun.stop_date field. If this field is null/None then the status is "Running", otherwise it is "Stopped".
In the current TR search page for example we query the TestRun.filter API with a
stop_date__isnull=True parameter.

How do i save exact values as displayed in JMeter test results including min, Max, avg values...?

I am trying to save test results as displayed in Summary, Aggregate report table but the results are not saved as the results displayed in the GUI while running jmx script.
I already tried to use Synthesis report too to get the results but still it does not work.
No error messages are displayed though.
I am assuming that you are running in non-gui mode. Please check the below CLI sample:-
jmeter -n -t D:\TestScripts\script.jmx -l D:\TestScripts\scriptresults.jtl
This will generate the jtl file at the end of the execution. You can then import this file in different listeners (Summary, Aggregate etc).
If in GUI mode. Then, use simple data writer or view result tree to generate the jtl file. Once completed, use summary report "Filename" field to point generated file as input as shown below:-
Then, use "Save Table Data" button to generate a summary.csv file.
Hope this helps.

Pass parameters to #Cucumber.Options dynamically

I am using cucmber+selenium. Is there a way i can pass options to #Cucumber.Options dynamically. Something like-
features="src/YahooSearch.feature" // i want to take this feature file names from excel & put here...
One way of setting it is through the System.setProperties() method.
Say, if my resources/features folder has all the necessary features, I can simply instruct Cucumber to scan for all the features in the folder like,
String features = "/src/main/resources/features";
System.setProperty("cucumber.options", features);
Also, you can instantiate your RuntimeOptions dynamically like
new RuntimeOptions(features);
You could code something simple by passing command line parameters and retrieving them using ENV['xxx'].
Please see this post
Instead of using Junit, use TestNG to invoke feature files. The flow goes like, Read from Excel and with the data generate testng XML suite dynamically to invoke each feature file. Please find the reference below,
https://github.com/sahajamit/cucumber-jvm-testng-integration

How to generate testNG report with assert pass or fail information

Hi I have a testNG class with Assert.assertTrue(true, "PASS"); and Assert.assertFalse(false, "FAIL"); statements. After the execution I am not able to find these PASS and FAIL result in the HTML report generated. I googled and found these may not be displayed in the report generated. So my question is, if testNG report does not provide this feature, is there any other reporting with which I can find these data after execution of my test in my report?
To log the information from the script to the HTML report we must use the class org.testng.Reporter. Now to print the data to the report we must use Reporter.log("PASS/FAIL");.
if you use Assert.assertTrue(condition, message); then when the condition is fail means it does not returns true, then the message is printed. So if assertion is true or pass then message is not printed.
To customize the HTML reports in TestNG, you need to use TestNG Listeners. below link will help you
http://testng.org/doc/documentation-main.html#logging-reporters
Let me know, if it is what you looking for.
Thank You,
Murali
If you want to fail the same Test case then you need to add Assert.fail() in your test case. Then it will display as fail in your report.

Resources