Skip to content
Advertisement

Tag: unit-testing

How to unit test methods together with its constraint validators (which some should be mocked out)?

My app has a service layer which is composed by CDI applications scoped beans: When a method gets called, an interceptor (in my case BValInterceptor.class from Apache BVal) checks if the method contract is respected by checking the annotations and validating the parameters accordingly. As you can see, there are some custom constraints like @SectionExists, @PostExists that may hit the

No runnable method in JUnit test Suites (Initialization error)

I am trying to implement JUnit TestSuites with my 3 Test Classes and run them at the same time. But when ever I run that test suite it gives me error as Initialization Error with “No runnable method found.” This is my test Suite class named as AllTests.java This is JUnitTesting_AddPatientPage.class This is my JUnitTesting_DentalCategoryPage.class This is my JUnitTesting_LoginPage After

Spring Boot service layer: Unit or Integration tests?

I have a service: I have written Integration tests for both database (BookRepository) and controller layer (BookController which uses BookService). I can’t find anywhere examples of integration tests for service layer. If I write unit tests properly, is there any use case for writting integration tests for it? As far as I can tell (it’s not a rule, but common

How do I compare Integer and Long types with Junit?

How do I compare Integer and Long types with Junit ? The result of assertThat(poiList.get(0).get(“id_pk”)).isEqualTo(member.getId_pk()); is: The two types are: How can I compare 1 and 1L to be equal? best regards Answer You can convert Integer to Long via java.lang.Integer#longValue: BUT beware of Null pointers, if poiList.get(0).get(“id_pk”) is null then a Null Pointer Exception will be thrown!

Advertisement