How to handle exceptions from failed xUnit tests? - xunit

I want to handle exceptions from failed xUnit tests to save exception details to my generated html report.
I guess I have to add this feature to my custom test framework (inherited from XunitTestFramework) but where should I put try/catch block?

Related

Mockito unfinished stubbing exception detected ONLY in Intellij Debugger

The problem only occurs when I am trying to debug a test via the IntelliJ debugger. It does not happen when I just simply run the test.
CustomerChoiceRepository is a normal Spring Boot JPA repository which here is being mocked with #Mock.
When this line executes in the debugger I get the following error in the watch section of the variables:
The entire error message is:
Method threw 'org.mockito.exceptions.misusing.UnfinishedStubbingException' exception. Cannot evaluate com.item.repository.jpa.CustomerChoiceRepository$MockitoMock$1318657964.toString()
Again this is only is detected in the IntelliJ debugger, as a result the test fails only when I am debugging it.
So my question is: what is happening here?
Is this a bug ? Is this something that I fail to understand because I do not know the internals of Mockito particularly well ?
Your IntelliJ is calling toString on the mock during stubbing, which causes the exception.
Check your debugger settings
By default, IntelliJ calls toString on objects in debugger window, but only on objects that override that method. This behaviour is customizable, currently in Preferences -> Build Tools -> Debugger -> Data Views -> Java -> Enable 'toString' object view, but the settings mey differ between IDE versions.
See:
Is it possible to tell IntelliJ IDEA to automatically invoke toString() on the objects inspected in watches, variables, tool tip windows?
Don't call methods on mocked object during stubbing
See:
How do Mockito matchers work?
How does mockito when() invocation work?

Jasmines is a JavaScript test API or test runner?

I have a confusion with Jasmine. This is API or runner?
If it's API, i will use to write automatic test code.
If it's test runner, what kind of test application can be deployed?
Sorry if i miss any information!

Is there a Web-UI out there for creating test's using htmlunit?

I want to be able to create the test's inside the Web-UI instead of writing them in code. Also i want to automate the tests and have extensive reporting.
I am restricted to htmlunit because the websites i am testing are testable with htmlunit.
You can define the test steps in other ways, see WebDriver recorder, WebTest and Wetator.
There is Spring MVC Test HtmlUnit also.

Report failures in TestNG framework

I have developed TestNG framework and implemented Maven
When I run the script, the results are generated and in the target folder, when I open index.html, all the scripts are displayed as Pass though it failed.
I have used java verifications (reporter.log)
Can someone suggest me on how to change the java verifications to TestNG to view the failures?
Thank in advance
Reporter.log is just for logging statements in the report. You need to use assertions to do your verifications. Try out the Assert class in Testng.

Error resolving template with Thymeleaf from test execution environment using Spring 3.2 Test Framework

Just trying to use the new features from Spring 3.2 testing framework in order to have real integration tests on the web layer.
I'm running across a problem when triggering the tests with the "SpringJUnit4ClassRunner" in Spring 3.2 because the template engine complains about not being able to resolve the template name:
2013-06-28 09:29:18,372 ERROR TemplateEngine - [THYMELEAF][main] Exception processing template "mobile/index": Error resolving template "mobile/index", template might not exist or might not be accessible by any of the configured Template Resolvers
Of course, the engine is searching for the resource around /WEB-INF/views/mobile/index.html, what is correct in a normal execution mode, but does not exist along the test execution environment in the class path with: *classpath (src/test/resources) in a Maven based project * /WEB-INF/views/mobile/index.html
Is there anyway to make the engine get the resources from the "real path" in order not to maintain a copy of each html view in the test classpath?
Thanks in advance,
One solution is having all the views under "/src/main/resources/views" and using the
org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
This way you don't have any dependency (rather than using the "FileTemplateResolver") on the system and also you do not need having any duplicated spring configuration files for the test execution context.
Still it's a bit weird for me having the views in there but... Why not?
Any comment/suggestion over having the views under resource folders?

Resources