use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class Selenified method startTest.
/**
* Gathers all of the testing information, and setup up the logging. If a
* selenium test is running, also sets up the webdriver object
*
* @param dataProvider - any objects that are being passed to the tests to loop
* through as variables
* @param method - what is the method that is being run. the test name will be
* extracted from this
* @param test - was the is context associated with this test suite. suite
* information will be extracted from this
* @param result - where are the test results stored. browser information will
* be kept here
* @param selenium - is this a selenium test. if so, the webdriver content will
* be setup
*/
protected void startTest(Object[] dataProvider, Method method, ITestContext test, ITestResult result, DriverSetup selenium) {
String testName = TestSetup.getTestName(method, dataProvider);
String outputDir = test.getOutputDirectory();
String extClass = method.getDeclaringClass().getName();
String description = "";
String group = "";
Test annotation = method.getAnnotation(Test.class);
// set description from annotation
if (annotation.description() != null) {
description = annotation.description();
}
// adding in the group if it exists
if (annotation.groups() != null) {
group = Arrays.toString(annotation.groups());
group = group.substring(1, group.length() - 1);
}
while (test.getAttribute(testName + INVOCATION_COUNT) == null) {
test.setAttribute(testName + INVOCATION_COUNT, 0);
}
int invocationCount = (int) test.getAttribute(testName + INVOCATION_COUNT);
Browser myBrowser = browsers.get(invocationCount);
if (!selenium.useBrowser()) {
myBrowser = Browser.NONE;
}
DesiredCapabilities myCapability = capabilities.get(invocationCount);
myCapability.setCapability("name", testName);
this.capability.set(myCapability);
OutputFile myFile = new OutputFile(outputDir, testName, myBrowser, getTestSite(extClass, test), test.getName(), group, getAuthor(extClass, test), getVersion(extClass, test), description);
if (selenium.useBrowser()) {
App app = null;
try {
app = new App(myBrowser, myCapability, myFile);
} catch (InvalidBrowserException | MalformedURLException e) {
log.error(e);
}
this.apps.set(app);
this.calls.set(null);
myFile.setApp(app);
if (selenium.loadPage()) {
loadInitialPage(app, getTestSite(extClass, test), myFile);
}
} else {
HTTP http = new HTTP(getTestSite(extClass, test), servicesUser, servicesPass);
Call call = new Call(http, myFile, extraHeaders);
this.apps.set(null);
this.calls.set(call);
}
this.browser.set(myBrowser);
result.setAttribute(BROWSER_INPUT, myBrowser);
this.files.set(myFile);
}
use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class ServicesErrorIT method comparePatchResponseCode200Test.
@Test(groups = { "integration", "services", "httppatch" }, description = "An integration test to verify the response code from a patch call")
public void comparePatchResponseCode200Test() {
JsonObject request = new JsonObject();
request.addProperty("id", 1);
request.addProperty("title", "foo1");
request.addProperty("body", "bar");
request.addProperty("userId", 4);
// use this object to verify the app looks as expected
Call call = this.calls.get();
// perform some actions
call.patch("posts/4", new Request(request)).assertEquals(200);
// verify 2 issues
finish(2);
}
use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class ServicesErrorIT method compareGetResponseCode200Test.
@Test(groups = { "integration", "services", "httpget" }, description = "An integration test to verify the response code from a get call")
public void compareGetResponseCode200Test() {
// use this object to make calls
Call call = this.calls.get();
// perform some actions
call.get("posts/").assertEquals(200);
// verify 2 issues
finish(2);
}
use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class ServicesIT method compareGetResponseBadCode201Test.
@Test(groups = { "integration", "services", "httpget" }, description = "A negative integration test to verify the response code from a get call")
public void compareGetResponseBadCode201Test() {
// use this object to verify the app looks as expected
Call call = this.calls.get();
// perform some actions
call.get("posts/").assertEquals(201);
// verify one issue
finish(1);
}
use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class ServicesIT method comparePostResponseBadDataTest.
@Test(groups = { "integration", "services", "httppost" }, description = "A negative integration test to verify the data from a post call")
public void comparePostResponseBadDataTest() {
JsonObject request = new JsonObject();
request.addProperty("title", "foo");
request.addProperty("body", "bar");
request.addProperty("userId", 2);
JsonObject response = new JsonObject();
response.addProperty("userId", 1);
// use this object to verify the app looks as expected
Call call = this.calls.get();
// perform some actions
call.post("posts/", new Request(request)).assertEquals(response);
// verify one issue
finish(1);
}
Aggregations