Spock test being Ignored when Spring context cannot start - java

I have problem with Spring Spock integration.
I have SpringBoot test in Spock which set up Application Context.
If for some reason Spring context is broken (for example missing Autowired dependency) then all Spock tests in the test class are being Ignored and the build is successful.
Is there any solution to fail build or do not Ignore Spock tests if Application context has failed ?

I have figured it out. It turned out that above behavior is due to bug in maven-surefire-plugin v.3.0.0-M4. In version 3.0.0-M7 the build is failing as expected.

Related

Use Karate framework with Fail Safe and Sure Fire plugin [duplicate]

Is there a way to run Karate test during maven's integration test phase? It seems that surefire plugin is hardcoded into Karate. I have tried to override it using failsafe plugin but with no luck. I don't want test to run along with unit tests.
Thank in advance!
It seems that surefire plugin is hardcoded into Karate
I'm not sure where you got that impression, but no, the surefire plugin is not hardcoded into Karate.
Keep in mind that the simplest way to not run a JUnit test via surefire is to not use the *Test.java naming convention.
I think the solution for you is simple, whichever JUnit test is the "entry-point" for your Karate tests (the parallel runner is recommended) - just use the failsafe naming conventions.
And then, just include the failsafe plugin as per the examples and it should work. If you have trouble getting that to work (unlikely), then you should look at maven profiles.
EDIT: also see this comment: Is there a way to run Karate tests as an integration test suite against a pre-booted spring boot server?
Turns out that I cannot be done and it is a limitation of Maven, not Karate. Howto add another test source folder to Maven and compile it to a separate folder? - Here is my test project to prove it out: https://github.com/djangofan/spring-boot-hello - Thanks for leading me down what appears to have been the correct path to discover the limitation. Using Gradle would likely solve my issue but that is not an option on my project. If I use Karate for "separated integration tests", I need a separate mvn test module.

JDK10: Unable to find a #SpringBootConfiguration, you need to use #ContextConfiguration or #SpringBootTest(classes=...) with your test

I have created a simple Spring Boot application, starting of from the Spring Initializr. I added Spring Web MVC and Spring Actuator. After that, I added a HelloController which just returns a Hello message. I am using JDK 10. When I run Maven clean install, I am getting the following error:
java.lang.IllegalStateException: Unable to find a #SpringBootConfiguration, you need to use #ContextConfiguration or #SpringBootTest(classes=...) with your test
When I remove my module_info.java file, everything runs ok (also if I run it with module_info.java and Maven option -DskipTests).
A sample project with the problem is available at the following location: https://github.com/mydeveloperplanet/myfabric8planet/tree/feature/surefire-problem
I already added the following fix concerning the org.ow2.asm dependency.
I do not have any tests, but I am wondering why this simple example is not working when I am using Java Modules.
Am I doing something wrong or is this a bug in the Maven Surefire plugin (or in Spring)?
You checked the structure of your project packages .
Why this when the package are unorganized spring can not find #Controller tag .If you want to send a print screen of the project I can have a better look .
My email mafujshikder01#gmail.com

Spring circular dependency fails on Linux but works on Windows

Working on a Spring Boot 1.3.3 / Spring Framework 4.2.5 project, I faced a circular dependency (ServiceA autowired in ServiceB, and ServiceB autowired in ServiceA - injection is done via constructors). I solved this problem with some refactoring to delete this circular dependency.
Meanwhile, I noticed that the code (TestNG unit tests) worked on Windows (Windows 7, Java 8), and failed on our Jenkins CI (Linux).
-> Is there any reason to explain why it worked on Windows ? I'm trying to make my Windows local builds to reflect CI builds as much as possible.
//edit -> it may be an important information: I can't give an accurate number, but ~75% of Linux builds fail and ~25% don't fail (still on Linux). There is no random condition in pom.xml, but I probably miss something...

Spring 3.0.5 Junit testing issue

I wanted to do spring junit testing to be implemented in my project, I am facing an issue. 1.I wanted a scenario where i can use one spring version jars for junit(src/test) and another spring version of jars for the running main java class(src/main) is it possible. I mean when spring is in testing phase it should use the spring 3.2.4.release and while building the ear it should use 3.0.5.release jars. is it possible.2.since the project is in 3.0.5.release and we wanted to use #WebAppConfiguration for testing which is not allowed in spring 3.0.5.release is there any way to do this (#WebAppConfiguration) in spring 3.0.5.release

Hibernate: How to start a single test from the Hibernate test suite?

Hibernate has its own test infrastructure, that can be used to test Hibernate and its various dialects.
The infrastructure is based on JUnit (the Tests) and Gradle (automation of the test process).
More on it you can find here:
https://github.com/hibernate/hibernate-matrix-testing
https://github.com/hibernate/hibernate-orm/wiki/Hibernate-JUnit-Infastructure
You can start all tests from the test suite using gradle:
gradle hibernate-core:matrix_mysql51
In this case all tests of the hibernate-core module will be started.
There are more than 4000 tests in the module.
I would like to start only some of them.
How do it do it?
Is it possible to use the same testing infrastructure, but start single tests from the testsuite?
gradle hibernate-core:matrix_mysql51 -Dmatrix_mysql51.single=annotations/EntityTest

Categories