I have been asked to create some automation tests to test an API for a project. I am fairly new to automation testing with limited knowledge of java. The instructions I have been given include; create a BDD style test suite using cucumber/gherkin syntax, utilizing Apache fluent-hc to interrogate the API. I have also been asked to create the test suite using Java. How can I utilize 'Apache fluent-hc' to test my API and can this be done via a Java IDE like 'IntelliJ IDEA'? Thanks
That's indeed a very general question. I can just say in really short "yes you can use IntelliJ IDEA" for all Java related development.
From the other point, it is something that you have to learn and understand your own, before starting any development, as a sample, in which way your BDD tests will be developed based on the API technology and as you said that you have limited knowledge of Java I would suggest you read first how to create API in Java, of course, it all based on your requirements, but I prefer API development using Spring Boot.
And if you are interested in that, I will post my blog post URL here later on where I'm describing from 0 to end how to cover APIs with BDD (currently it is under preparation, next week I will post it).
Meanwhile, I will suggest you read this blog and earn some knowledge of APIs and their testing.
UPDATE: Here is the blog post about BDD that I promised - https://www.blazemeter.com/blog/api-testing-with-cucumber-bdd-configuration-tips
Related
It took me about 5 minutes to use the Google Translate REST API from Javascript, NodeJS, WGET and Java via Sun's Jersey library, but I cannot find any working examples for the current version of the official Google Java Client (rev41), or how to configure it using Maven. I sat for an entire morning trying to work it out from the source code (and swearing a lot) to no avail. Working out the Maven stuff was easy enough but I cannot for the life of me work out how to use the Java API - a crazy situation as it took so little time using basic generic technology.
For reference - this is my Maven config:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-translate</artifactId>
<version>v2-rev41-1.20.0</version>
</dependency>
My bigger question to the lovely Google folk is - why is the Java library harder to implement than using straight REST? Surely the sole purpose of the Java library is to provide a wrapper that makes using Google Translate simpler, and there are only about 3 REST calls to wrap, how hard can it be? What exists now would appear to be the opposite: a number of web articles actually recommend using a thirdParty non-official Java library, or even Google's text-to-speech service (How to use Google Translate API in my Java application?). All of this suggests to me that this area needs some attention or should be thrown in the bin, it's not currently adding any value.
The second part of the question is not answerable, as it isn't specific and instead seems like a loaded question. I'll just answer the first part.
The Maven config can be found in the Translate documentation for the Java API Client. In the "Add Library to Your Project" section, click "Maven."
Although there is not an example specific to Translate, you can take a look at other samples, such as the CalendarSample. If there is a specific step that still isn't obvious please bring it up specifically, such as OAuth, constructing the Translate class, or knowing where to start. I'll also note that the Translate JavaDocs are linked to from the above documentation.
I need to make a demo web project with extensive support for reading and editing WM(T)S, like this project. For technology Java or .NET are possible solutions. I tired GeoMajas for couple of days now, but it get annoying error about refresh of main map that I can't solve. Also, community support is non-existing as there are only mialing lists about development of GeoMajas, no forum to help solve this problem. Any advice on what framework to choose?
I would suggest looking at one of the following
Openlayers http://openlayers.org/
Leaflet http://leafletjs.com/
Geo Ext http://opengeo.org/technology/geoext/
These are all java script libraries so if you really need to you can inlcude them in a Java or .net based website.
If your looking for a more complete framework I would look at the OpenGeo suite. If you download it and look at the Geoexplorer app makes a good starting point and it uses the OpenGeo GSP Libries which are basically a warpper around GeoExt and Openlayers.
I am trying build an automated testing framework for some of our internal web services (java) at work. Each service has a set of APIs (3-5), although this could be relatively easy to achieve, the problem comes with some APIs which do not behave as pure functions, ex: something like persistX, this could store something in a database and returns an exception incase of failure.
There is no easy way to validate since there is no output here.
So I was wondering if this could a a bit generalized, say while testing the API, the user could provide a simple plugin or script to the framework of some sort that could validate the test. This is just one idea would be great if someone can tell me some better ones or any resources about the same.
Thanks
I recommend the robot framework. It is a keyword driven framework written in python. Because of that, you can run it in the JVM with jython which means you can extend it with java code (or python, of course). I've sucessfully used it to call APIs, then verify the result by peeking into a database, or querying the file system.
It also works on the .NET platform, has a selenium module for testing the front end, a jenkins plugin, and several other tools. It's very extensible and flexible.
What you are looking at is the application of black-box and white-box testing and the tools that support both.
For the web services that return a proper response you can perform black-box testing by verifying the data in returned response. SoapUI is the best tool for this.
For the APIs which do not behave as pure functions, you do white-box testing by verifying its side-effects like persistence, event generation, logging etc. For this you like programmable tools and SoapUI may or may not be the correct option.
We do both at our work and after evaluating multiple tools/frameworks (SoapUI, RSSPec, Robotframework), I chose Spock. Why spock?
It allows you to write intention revealing tests in BDD style
We are Java shop and we want to use the same familiar language for automation as well but with simplified syntatic sugar. And spock is all groovy based.
Excellent Webdriver/Selenium 2 support (including PageFactory) with Geb
It is built on top of JUNIT so all the plugins of JUNIT can be leveraged (code coverage, hudson/jenkins integration, etc)
Lot of webservice APIs and XML DSLs (no need to work with XPATH for simple scenarios)
Simplified setup (unlike robotframework it doesnt require python, jython setup)
etc....
I know cucumber from the rails community, and it seems to potentially be used in java.
Has anyone actually used it successfully on a project? Any issues with it?
I am thinking selenium is probably the most stable solution for integration testing a spring app?
With selenium, I guess the best way would be to use the browser add-on correct? I am looking for a simple and effective solution that isn't time consuming to create/maintain and run.
Sure, it's viable, although I used JRuby for Java library integration.
Personally, I'm not a fan. I much prefer easyb, although part of the reason was an easier transition for some devs from Java to something higher-level. I find Cucumber a bit hoop-ful, but YMMV.
We had a few glitches making easyb output play nice with Hudson, but relatively minor.
I'm going to give a talk about using Java and Scala together and I want to investigate some projects (large and small) which contains Java and Scala code.
If you know links to correspondent projects post them here.
This page on the Scala wiki is a good starting point...
The various scala testing frameworks come to mind. They all have some integration with JUnit or TestNG
Gimd is one example of small project: http://code.google.com/p/gimd/
Although development stalled for a while because I'm busy with other duties it already contains some examples of Scala<->Java integration. Notably:
unit tests are written using junit
Gimd is using JGit (library in Java) as underlying layer
While working on Gimd I found that using Java from Scala is mostly easy and seamless the contrary is not always true. It's not really a fault of Scala as it's simple manifestation that Java is a less expressive language.
Unfortunately I don't know any open source project but I have worked on very large projects over the last few years that have java and scala interacting and my experience has been mostly very positive. If I had one piece of advice it would be to use scala-javautils. It's a life saver and is far better than the scala jcl code. Before we started using it trying to get some interactions involving collections was heart-breaking. However I'm led to believe 2.8 will solve this.
In general I find the interactions between scala and java very close to using one language.