How to Print Console.Log to JUnitXmlReporter using protractor? - jasmine

I am doing a protractor test. I want to print the messages i wrote inside the test using Console.Log("Message") to JUnitXmlReporter(the XML file). OR .... is ther anyway to create a custom Output files using protractor. I want to print a Data i fetched from the test to a File.

Have you tried:
https://github.com/larrymyers/jasmine-reporters
from their page:
JUnitXmlReporter - Report test results to a file in JUnit XML Report format.
NUnitXmlReporter - Report test results to a file in NUnit XML Report format.
you can also create a custom one:
http://jasmine.github.io/2.1/custom_reporter.html
hope it helps

You can keep things simple. You dont need any custom reporters to write the console information to a file. Just use the terminal output redirecting operator.
protractor conf.js > consoleLog.log
To append
protractor conf.js >> consoleLog.log
Check here for more options

Related

JMeterLibException: 'Incorrect log file format'

JMeter 2.12
python 2.7.18
I'm getting JMeterLibException: 'Incorrect log file format' for the below code using robot framework
${logPath}= set variable C:/Tests/output1.log
run jmeter C:/Tests/apache-jmeter-5.4.1/bin/jmeter.bat C:/Tests/100users.jmx ${logPath}
${result} analyse jtl convert ${logPath}
log ${result}
FOR ${ELEMENT} IN #{result}
log dictionary ${ELEMENT}
It seems that your "JMeterLib" (whatever it is) expects some specific JMeter .jtl file format and JMeter 5.4.1 default settings are not compatible with it.
Unfortunately we cannot really help you without seeing this "JMeterLib" output or source code so I can only provide a generic piece of advice:
JMeter .jtl file output is controllable via special set of properties responsible for Results file configuration, once you determine what exact metrics does your "JMeterLib" expect you can amend JMeter's configuration accordingly in order to make it compatible with your 3rd-party software assumptions.
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
You should use jtl file extension instead of log
${logPath}=set variableD:/Tests/output1.jtl

Getting error while running merged jtl files

I am trying to generate the report in JMeter by merging .jtl files content getting below error -
File '/home/ajij/jmeter_tests_cli/merged.jtl' does not contain the field names header, ensure the jmeter.save.saveservice.* properties are the same as when the CSV file was created or the file may be read incorrectly when generating report
An error occurred: Error while processing samples: Consumer failed with message :Could not parse timeStamp <timeStamp> using format defined by property jmeter.save.saveservice.timestamp_format=ms on sample timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
Note -
If i run 2 independent jtl files then will get run successfully
Command to execute JTL file -
../Documents/apache-jmeter-5.2/bin/jmeter.sh -g merged.jtl -o ./folder
JTL File content -
https://drive.google.com/file/d/1j6kZ7mUj0IbT6hWS0KR3BsZVK4t6wQzj/view?usp=sharing
Quick Help will be appreciated !!!
As per JMeter's documentation:
The dashboard generator is a modular extension of JMeter. Its default behavior is to read and process samples from CSV files to generate HTML files containing graph views. It can generate the report at end of a load test or on demand.
As of current latest stable version JMeter 5.3 generating dashboards from .jtl files in XML format is not supported so either re-run your test with the following JMeter property defined:
jmeter.save.saveservice.output_format=csv
or review your way of "merging" the result files, if it supports CSV output format - go for it.
Did you try removing the XML tags? I haven't tested yet using the CSV you shared, but it might be enough removing the XML tags and merging "manually" the files, I'd merge the files by removing the second headers and the XML tags, remember JMeter process the requests by time so it will order the requests by timestamp

Generate Swagger json at Build time

I'm working on a ASP.NET Core WebAPI project and I'm trying to find a way to generate swagger json at build time ?
As i'm working with 4 environments, i'd like to have 4 swagger.json with a different name of my choice, like:
swagger_{appName}dev{buildNumber}.json
swagger_{appName}demo{buildNumber}.json
swagger_{appName}int{buildNumber}.json
swagger_{appName}staging{buildNumber}.json
Is it also possible to edit the fields in the json ? I'd like to edit (depending of the environment) the following fields : host, schemes and basePath.
I'm using Swashbuckle.AspNetCore but it appears it doesn't have an option to do such task or am I wrong ?
Thanks in advance
You have the option of generating OpenApi json file(s) from the command line without deploying using the Swashbuckle.AspNetCore.Cli nuget package.
The command will look something like this and can be added as a "post build" script
dotnet <nugetpackages>\Swashbuckle.AspNetCore.Cli\bin\$(Configuration)\netcoreapp<ver>\dotnet-swagger.dll tofile --host http://localhost --output swagger.json <bin>\<AssemblyName>.dll v1
more details can be found here https://github.com/domaindrivendev/Swashbuckle.AspNetCore#swashbuckleaspnetcorecli
I'm not sure about generating separate files for each environment offhand
The simple way is using PowerShell task to update json file and save with another name.
Simple workflow:
Read the file through Get-Content script
Using ConvertFrom-Json to converts content to object
Set the property value to update object
Using ConvertTo-Json to convert an object to a JSON-formatted string
Using Set-Content to write content to a file
For detail code, you can refer to this thread: how do I update json file using powershell.
The build number value is stored in the predefined variable: Build.BuildNumber (PowerShell: $env:BUILD_BUILDNUMBER)

Jasmine + Istanbul only

I want to get code coverage directly in browser, when running my Jasmine specrunner.html. All examples, that I have found with Jasmine+Istanbul also use Grunt/Gulp/Karma or some other cmd line tool. I don't want that.
Is there a way to get results displayed in browser with Jasmine + Istanbul, or is a cmd test runner a must here?

Code analysis VB6 Project with CodeSmart via command line

im using CodeSmart 3.4.6.297 to get code metrics from my vb6 projects.
now i want to include codesmart in my build-process using TeamCity.
i know that codesmart can be user in the command line. this works for me. i have my command line.xml file:
<sourcemonitor_commands>
<write_log>true</write_log>
<command>
<project_file>Path to xyz.smproj</project_file>
<project_language>VB</project_language>
<modified_complexity>true</modified_complexity>
<file_extensions>*.cs,*.Designer.cs,*.frm</file_extensions>
<source_directory>Path to Project</source_directory>
<include_subdirectories>true</include_subdirectories>
<checkpoint_name>Baseline</checkpoint_name>
</command>
</sourcemonitor_commands>
which generates a projectXYZ.smproj file.
My question now is...
how do i export data (code metrics like lines of code) from this smproj file using a console command?
i can get code metrics when i open my projectXYZ.smproj file in the codesmart IDE and exporting data using the menue "file...export Checkpoint details" but i need this in a console command
Any ideas?
Greetings
SLimke
Got it myself. had to add an export area to the command block
<export>
<export_file>PathToProject\Checkpoint1.xml</export_file>
<export_type>2 (checkpoint details as XML)</export_type>
<export_option>1 (do not use any of the options set in the Options dialog)</export_option>
</export>

Resources