Spring Boot BDD Testing with serenity - java

we have a spring boot application which we want to test via serenity (former Thucydides). Theoretically the tests can be run (if i test for example www.google.com everything works fine) but I want to test my own application and not google ;)
So I need to start the application before running the tests. Normally we have an annotation
#RunWith(SpringJUnit4ClassRunner.class)
at our test class. but with Serenity and cucumber we need
#RunWith(CucumberWithSerenity.class)
and it is not possible to add 2 #RunWith annotations.
What is the best way to get the tests wit Serenity and Cucumber running?

Upgrade to Spring 4.2.1 and you should be able to use the Serenity runner:
http://docs.spring.io/spring/docs/4.2.1.RELEASE/spring-framework-reference/htmlsingle/#testcontext-junit4-rules

Related

Unit testing a Configuration in spring Batch which runs in spring boot application

I am Using Spring boot application to run spring batch and I have a Config java class which loads all configuration related stuff like getting some values from properties file and setting them, calling reader,writers etc.
I am trying to run a junit for just few methods in that config class from my unit test class. how can we achieve that. I am trying to use SpringRunner Can someone through some light .

Unit Test Mock for Spring Boot Rest Api

A we are using Spring Boot Rest Api for service calls.
We can use Junit for unit test cases I guess.
But need to know other suitable tool or framework to mock Unit Test for Spring Boot Rest Api () other than junit.
jUnit
SureAssert
Mockito
JS Test Driver (Like Selenium -> UI)
Selenium (UI Testing)
TestNG
jTiger

How can i automate a spring boot batch process?

I am trying to see if i can automate a spring boot batch processing built with JDBC template and i have never worked on it. i automate web based projects using cucumber and selenium web driver. Is it even possible? help please.
Thanks
If I understand you correctly, it is possible to write automated tests for spring boot batch application using cucumber.
This is how I have it implemented -
Dependencies - cucumber-java, cucumber-junit, cucumber-spring
gherkin features like usual
cucumber test cases - use SpringApplication.run(YourApplication.class) to run the Spring Boot application, an use SpringApplication.exit() - to verify exit status codes for Batch as needed.
Here is an article which I found helpful for integrating cucumber with Spring Boot - http://www.baeldung.com/cucumber-spring-integration

Is it possible to use JExample and Spring integration test at the same time?

I'm testing a Spring web MVC application with heavy RESTful invocation that POST and DELETE a remote resource on demands.
When I'm trying to run integrated test, obviously I need to test POST first and then DELETE second. Unfortunately JUnit doesn't support such dependency test, and the vanilla JExample class cannot be run with Spring application context. Is there a feasible way of using both?

How to start Grails as a web app when runnning integration tests

I'm trying to test my grails app using integration test that makes http requests. Actually it's a selenium/tellurium test, but it doesn't matter. But as i see when i running grails tests it doesn't starts web container, the same time i see many examples in blog articles that people tests grails app using selenium and other test tools that requires http access.
I've create an empty grails app:
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate -DarchetypeGroupId=org.grails -DarchetypeArtifactId=grails-maven-archetype -DarchetypeVersion=1.3.4 -DgroupId=example -DartifactId=testportapp
cd testportapp/
mvn initialize
mvn grails:test-app
Tests PASSED - view reports in target/test-reports
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
thats ok.
and now add an integration test that tries to connect to grails test/integration/ListenPortTest.groovy:
class ListenPortTest extends GroovyTestCase {
void testPort(){
def s = new Socket("localhost", 8080);
s.close()
}
}
and run test again. Now we receive following exception:
Connection refused
java.net.ConnectException: Connection refused
....
I've checked it also by using browser, wget and netstat, and looks like grails not started or not opened any port.
And the question:
How i can configure grails to open an port when executing integration tests?
Grails supports two types of tests by default, unit and integration, plus functional testing using a plugin. Unit and integration tests are quite similar and are really both unit tests, except that integration tests have an initialized Spring application context, Hibernate configuration, in-memory database, etc. But no running web server - you need functional tests for that.
There are several options for functional testing, the most popular ones being WebTest: http://grails.org/plugin/webtest, the Functional Testing plugin: http://grails.org/plugin/functional-test, and the Selenium RC plugin: http://grails.org/plugin/selenium-rc.
The newest one is Geb: http://grails.org/plugin/geb and if you're looking for Selenium support it's going to be your best bet. The manual is at http://geb.codehaus.org/ and there was a recent blog post written about it here: http://blog.springsource.com/2010/08/28/the-future-of-functional-web-testing/
I think you are looking for this plugin
http://www.grails.org/plugin/functional-test

Categories

Resources