-1

I have developed an application with multiple producers & consumers using Spring boot & RabbitMQ. Application is working fine without any issues, but still i want to do unit testing & integration testing.I browsed google but no luck not getting solid use case to do testing Spring boot & rabbitMQ together.

So i would like to know which tool is best suitable for testing Spring Boot & RabbitMQ(atleast a hint of how to write a test case is appreciable)? I saw similar stackoverflow post but didn't get solution.Your help should be appreciated.

VelNaga
  • 3,593
  • 6
  • 48
  • 82
  • "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam." https://stackoverflow.com/help/on-topic – g00glen00b Jun 30 '16 at 06:59

1 Answers1

5

Not sure what are you looking for, but Spring Boot Testing framework together with the classical JUnit and Mockito are fully enough for unit testing.

In addition you can take a look into spring-rabbit-test library, where we have enough useful testing utilities: http://docs.spring.io/spring-amqp/docs/1.6.0.RELEASE/reference/html/_reference.html#testing

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Billan Let me have a quick look over it.I just want to write a automation testing to check the rabbitMQ functionality.The link you shared suits my scenario then definitely will upvote your solution. – VelNaga Jun 29 '16 at 16:27
  • Not sure why you should check the RabbitMQ functionality, because that is a RabbitMQ team responsibility. You have to check your application instead! :-) – Artem Bilan Jun 29 '16 at 16:30
  • I read the link you shared.In the link it is mentioned "Spring AMQP version 1.6 introduced the spring-rabbit-test". Currently i am using Spring AMQP version 1.4 so do we have any jar which supports older version. – VelNaga Jun 29 '16 at 16:33
  • While testing application we have to test everything including messaging part also i would like to know how efficiently we can test RabbitMQ with spring-test or JUnit or otherthings. Kindly correct me if i am wrong. – VelNaga Jun 29 '16 at 16:34
  • No, we don't. But you definitely should consider to upgrade to 1.6 since it is released already. – Artem Bilan Jun 29 '16 at 16:34
  • All those custom tools aren't intended to provide some efficiency. It's not their responsibility. So, if you can just rely on `spring-test` , JUnit and Mockito, that's fine. I really not sure how the tool should look which you try to find... Although I admit that I am not test driven developer :-) – Artem Bilan Jun 29 '16 at 16:40
  • Of-course i accept even i am developer but some how i am interested to do testing now.I am using spring boot version 1.3.5-release which contains spring-rabbit-1.5.6.jar.How can i upgrade it to 1.6.0 without affecting the spring boot version.Do you have any idea i know it's a separate question but based on our comments it is related to this question now :P. org.springframework.boot spring-boot-starter-amqp How to upgrade "spring-bbot-starter-amqp" alone? – VelNaga Jun 29 '16 at 16:50
  • You can just specify the proper `spring-amqp.version` property: http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-build-systems.html#using-boot-maven-parent-pom – Artem Bilan Jun 29 '16 at 16:58
  • @Attem Bilan I added following version number "1.4.0-RELEASE" but it throws missing artifact.I think it's not possible to upgrade "Spring-boot-starter-amqp" or we should should mention the proper version number.I saw the maven repository 1.3.5 is the latest stable version others are still in development.Kindly correct me if i am wrong. – VelNaga Jun 29 '16 at 17:02
  • 1
    See http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-build-systems.html#using-boot-maven-parent-pom. You have to specify in the `` the desired for Spring AMQP: `1.6.0.RELEASE` – Artem Bilan Jun 29 '16 at 17:04
  • Yes now it is upgraded to 1.6.0 but it is not pulling "spring-rabbit-test.jar". Also searched maven repository i didn't find any matching artifact for "spring-rabbit-test.jar".Do i missing anything here? – VelNaga Jun 29 '16 at 17:16
  • 1
    Not sure where are you searching, but it is here: http://search.maven.org/#search%7Cga%7C1%7Cspring-rabbit-test. Right Spring Boot doesn't know about that artifact. You have to included it as a `` manually in the `test` scope. – Artem Bilan Jun 29 '16 at 17:19
  • .Thanks a lot for your help.I searched in the following repository "https://mvnrepository.com".Now i got the test jar let me write the test cases. – VelNaga Jun 29 '16 at 17:22
  • I read the entire link but not getting few points.How we can run the test cases or it will automatically invoked by the container? – VelNaga Jun 30 '16 at 10:52
  • 1
    Which container? That is JUnit test, so any possible way to run is appropriate: mvn test, gradlew test, directly from IDE etc. – Artem Bilan Jun 30 '16 at 11:45
  • I am using Spring-Boot along with spring-rabbit-test and i annotated my main test class with @ContextConfiguration(classes=App.class) @RunWith(SpringJUnit4ClassRunner.class) But some how it is not picking the ApplicationContext.It throws exception "java.lang.IllegalStateException: Failed to load ApplicationContext". – VelNaga Jun 30 '16 at 12:05
  • I think that is fully different story, not related to testing for Spring AMQP. You should take a look down the stack trace to figure out what's wrong with that applicationContext – Artem Bilan Jun 30 '16 at 12:09