How to uploading test result in HP ALM - java

i want to run my test script written in Java+Selenium+TestNG in HP ALM. I created Vapi-XP test and batch file which run my test. But if test failed it will report a pass. How to uploading test result?
mycommand = "C:\PSelenium\RunVapi.bat"
TDOutput.Print "Starting " & mycommand
result=run(mycommand,0,true)
TDOutput.Print "Test ended with " & result

You might want to check Agiletestware Bumblebee integration platform which can help you to automate exporting results of Java+Selenium+TestNG tests into HP ALM. Check out this and this also.
Disclaimer: I'm developer of Bumblebee

You have 2 Global Objects in the scope of a VAPI-XP Test: CurrentRun, CurrentTest. They correspond to the Run and Test interfaces respectively. Setting the Status property on Both Objects should be the way.

Related

Parallel tests in Android with cucumber, appium and testNG in java

I have 5 real devices in which I want to execute 20 tests, for example: 4 tests in each device in parallel, that is, in device 1 test 1 is executed, when the test ends, test 2 follows, in device 2 test 5 , at the end of test 5, follows 6... I can only run 1 test on each device in parallel, when I run more than 1, the test fails. Is there a way to specify that the current test is expected to finish before the next one starts? I am using Cucumber, Appium, testNG
You've got to set dataproviderthreadcount somehow.
And that depends on how you run TestNG.
Via the CLI: https://testng.org/doc/documentation-main.html#running-testng
Via Maven: https://maven.apache.org/surefire-archives/surefire-2.21.0/maven-surefire-plugin/examples/testng.html

Integration Tests fail to connect, Manual Browser Test succeeds with Java RESTful Web Service with SpringBoot/Jsoup Integration Test

I'm trying to run the sample code in this book: Building RESTful Web Services with Spring 5 - Second Edition. You can download the sample code for free. In chapter 7, they have some sample code that includes some integration tests and unit tests all in same directory "chapter7\ticketmanagement/src/test/java/com/packtpub/restapp/ticketmanagement/". The unit tests work fine. The integration tests fail with "testUsersJsoup(com.packtpub.restapp.ticketmanagement.JsoupUserTest) Time elapsed: 1.011 sec <<< ERROR!
java.net.ConnectException: Connection refused: connect"
I experimented with changing the port from 8080 to 9090 in "ticket-management\src\main\resources\application.properties" (I also changed the hardcoded values in the integration test) and this did not help.
So "mvn test" produces the above error.
So does running them in spring tool suite.
I edited the original pom.xml and added the "maven-compiler-plugin" to specify java version 1.8. I'm running windows 10.
So the failing code is in "chapter 7\ticket-management\src\test\java\com\packtpub\restapp\ticketmanagement\JsoupUserTest.java".
Here is the failing code:
public void testUsersJsoup() throws IOException {
String doc = Jsoup.connect("http://localhost:9090/user").ignoreContentType(true).get().body().text();
_log.info("{test} doc : " + doc);
JsonParser parser = new JsonParser();
JsonElement userElement = parser.parse(doc);
JsonArray userArray = userElement.getAsJsonArray();
_log.info("{test} size : " + userArray.size());
assertEquals(4, userArray.size());
}
HOWEVER, when I type
mvn spring-boot:run
it starts successfully and I point my chrome browser to http://localhost:9090/user (or http://localhost:8080/user if I am using the original code) I see
[{"userid":100,"username":"David"},{"userid":101,"username":"Peter"},{"userid":102,"username":"John"}]
No connection error! The results look correct.
We know this is not a firewall problem because it is just with localhost and it works with chrome.
There is no proxy involved.
I think the ports are correct: I presently have 9090 in the application.properities file, and in the source code and in the browser.
"mvn clean" and then "mvn test" again did not help.
There are annotations to start the web app as exemplified here:
Spring Live Lessons Tutorial and they work. See %JAVA_BUILDINGMICROSERVICES%\livelessons-security\livelessons-security-basic\src\test\java\basic\BasicSecurityApplicationTests.java.
These annotations have been deprecated, and replaced by newer ones. The problem is that the author of this tutorial is not using theses new annotations correctly: he needs to also use #WebAppConfiguration and this requires some configuration arguments from the #SpringBootTest (which he is missing). Therefor it necessary to manually start the web server with "mvn spring-boot:run" in a separate process and then run the tests.
When I tried to use #WebAppConfiguation, I got other errors. I will document these errors in another post (some day).

Jmeter and Graphs Generator

I read (maybe not so carefully) the following link and link but despite my efforts, i can't succeed to generate my graphs.
(windows or mac).
I do have two scripts (as advised by Vincent DABURON).
Sorry but i have a french version of Jmeter, i can switch to an english one if needed.
Preliminaries :
/bin/user.properties has been updated.
jmeter version is 3.0 r1743807
1. FIRST SCRIPT : Measuring simple HTTP request
a. First one contains credentials to be given to IP, IP adress to test and a pause.
b. It is executed in non_gui mode with
jmeter -t myscript.jmx -n -l f:\data\jmeter\test-results.csv -JTEST_RESULTS_FILE=f:\data\jmeter\test-results.csv
c. I do have a csv file populated with the following (extract)
timeStamp;elapsed;label;responseCode;threadName;success;bytes;grpThreads;allThreads;Latency;SampleCount;ErrorCount;Hostname;IdleTime
10:24:10;302;10.107.25.219;200;Groupe d'unités
1-1;true;266;1;1;302;1;0;MYPC;0 10:24:11;182;10.107.25.219;200;Groupe
d'unités 1-1;true;266;1;1;181;1;0;MYPC;0
10:24:12;153;10.107.25.219;200;Groupe d'unités
1-1;true;266;1;1;153;1;0;MYPC;0 10:24:13;198;10.107.25.219;200;Groupe
d'unités 1-1;true;266;1;1;198;1;0;MYPC;0
2. SECOND SCRIPT : Generate graphs ( Saved in bin folder as jpgx.jmx )
a. directly under test plan, i have created a jp#gc - Graphs Generator.
- JMeter Results File : **${__P(TEST_RESULTS_FILE,f:\\data\\jmeter\\test-results.csv)}**
- filePrefix : PREFIX_
b. Running in console
jmeter -t jpgc.jmx -n
c. I don't have any images at all.
May someone guide me on what's wrong with it ?
Kind regards,
Pierre LAURENT
I have switch to a more recent technology ( JMeter / Influxdb / Grafana ) as perfectly described in this link.
Regards,
Pierre

Terminating an AWS Code Deployment with Java jar return value

I have an aws instance running with webservices that I want to test with a java application running JUnit. If I have a script that runs the jar during the validate services step of the code deploy process how does the code deployment handle the return value of the jar if a test fails?
Is it required that I catch exceptions thrown by the jar for the failing tests and call system.exit(-1) to have the script terminate the code deployment or does the exception thrown automatically give the return value of non-zero?
If you are running JUnit using JunitCore, it should return a non-zero exit code if any of the tests fail.
main
public static void main(String... args)
Run the tests contained in the classes named in the args. If all tests run successfully, exit with a status of 0. Otherwise exit with a status of 1. Write feedback while tests are running and write stack traces for all failed tests after the tests all complete.
Parameters:
args - names of classes in which to find tests to run
From: http://junit.org/apidocs/org/junit/runner/JUnitCore.html#main%28java.lang.String...%29

GWT JUnit Test - Is it possible to ignore same-origin policy

I am trying to run an asynchronous test and need to send a request to my server, which has a REST-API. So my problem is that the tests are executed on the local machine, but this obviously violates the same origin policy and I get a RuntimeError if I try to run the GWTtestCase:
com.google.gwt.http.client.RequestPermissionException: The URL http://<url-to-my-rest-service> is invalid or violates the same-origin security restriction
at com.google.gwt.http.client.RequestBuilder.doSend(RequestBuilder.java:394)
at com.google.gwt.http.client.RequestBuilder.send(RequestBuilder.java:242)
...
I know that I can run these tests manually, but with the latest updates of my browser (chromium), the GWT-Plugin was removed. So I don't know how to launch the tests in SuperDevMode.
Questions:
Is there a way to ignore the same-origin policy for the GWT JUnit Tests?
Can I change the browser which is used for the test to Chrome/Chromium?
How can I manually run the tests with SuperDevMode in a browser?
Edit:
If I want to run the tests manually I write the following into the terminal:
mvn gwt:test -Dgwt.args="-prod -userAgents safari -runStyle Manual:1"
Maven then will print an URL to the terminal which I should enter into the browser to execute the tests:
http://127.0.1.1:57818/<my-package>.JUnit/junit-standards.html?gwt.codesvr=127.0.1.1:40387
But if I enter this URL into my browser (Chromium) it will notify me that the GWT-Plugin is currently not installed. If I remove the part behind the question mark (like I do if I want to run the GWT-Code in SuperDevMode on the localhost) ?gwt.codesvr=127.0.1.1:40387 then the browser will show only a blank page, and also if I started the codeserver with:
mvn process-classes gwt:run-codeserver
the codeserver-bookmarks (Dev Mode On) are not working and GWT is not able to detect a module which is "compilable".
Question:
So how excatly do I compile the JUnit-Test-Module with the SuperDevMode?
You can't bypass the SOP, but you could use a servlet to proxy requests to your remote server (servlets declared with <servlet> in your gwt.xml files are honored by JUnitShell).
And if you want to run the tests in Chrome/Chromium, you can either use -runStyle Manual or Selenium (note: there's even a custom run style for PhantomJS), and because DevMode no longer works, as you noted, you'd have to run tests in prod mode: -prod -userAgents safari

Categories