Skip to content
Advertisement

Tag: testing

How to re run suite without using listener in testng

I had a requirement to re-run a complete suite from the TestNG test method itself if any of the test-case from the suite failed. Is there any way to call complete suite using an XML file or Test class within the Test method? The complete suite should re-run the after-class method or teardown test-case or last test-case @AfterClass or @AfterMethod

Testing a Spring ControllerMethod using Mockito which alters an entry in the db with Optional.map NullPOinterException

Im currently Testing my Controller methods. In one Method I add a Reisepunkt(travelpoint) to a Reise(travel), which is already saved inside a database. Using the generated-request.http API I can use the method to make entrys into the db. Now i wanted to write a test method just so I can get the hang of it. I always get a NullPointerException

Spring Mockito @BeforeAll mocking logic works on 1 test only

I have a problem with understanding why the logic mocked inside @BeforeAll works, but only for the first test. They work fine separately, copying the identical logic to both tests will produce the same result – 1 passed, 1 failed. What happens: in AboutUsService.update() on the first line appears the mistake at pageRepository.getByName(ABOUT_US_PAGE).orElseThrow(null); For the first test, the calling of

How to mock LocalDateTime.now() in java 8

Please, I am testing a functionality ABC that uses LocalDateTime.now(). In the methode ABC i’am comparing an entry date with the LocalDateTime.now() I want my test to be passed at any day so i have to mock the LocalDateTime.now() This is my test: I am using JAVA 8 the date shown in the console is always the real LacalDateTime not

response.jsonPath() has square brackets around the element, how do I retrieve the string value? Rest Assured

I have an HTTP response body that looks that this when I make a GET request: When I try to assert the results with “Rest Assured”, the name value is always wrapped in square brackets []. So the test fails with Expected “MyNameTest”, but was “[MyNameTest]” Can any one tell me how to resolve this? Answer You are accessing values

Advertisement