This option can only be used in the CLI today; we are going to add this as an option in the plugin in an upcoming release
This option will only help you for writing tests where the sandboxing policy is protecting you from potentially dangerous code. Are we able to successfully write tests for other parts of your code that don’t exercise JMX APIs?
Yes, Able to create test case but one thing i need to confirm it will create multiple test cases for one method. This is default behavior OR we can change it.
Also when we get the new version of diffblue with “–disable-security-policy” option
@GetMapping("/owners")
public String processFindForm(@RequestParam(defaultValue = "1") int page, Owner owner, BindingResult result,
Model model) {
// allow parameterless GET request for /owners to return all records
if (owner.getLastName() == null) {
owner.setLastName(""); // empty string signifies broadest possible search
}
// find owners by last name
String lastName = owner.getLastName();
Page<Owner> ownersResults = findPaginatedForOwnersLastName(page, lastName);
if (ownersResults.isEmpty()) {
// no owners found
result.rejectValue("lastName", "notFound", "not found");
return "owners/findOwners";
}
else if (ownersResults.getTotalElements() == 1) {
// 1 owner found
owner = ownersResults.iterator().next();
return "redirect:/owners/" + owner.getId();
}
else {
// multiple owners found
lastName = owner.getLastName();
return addPaginationModel(page, model, lastName, ownersResults);
}
}
We will write a test for each of the separate pathways thus covering all of the possible behaviour.
The option to --disable-security-policy in the plugin is currently scheduled within the next 4 weeks but this could change over time; I will keep you updated.
Can I ask what sort of project are you testing on and what are you looking to get from Diffblue Cover?
Project we are testing is mixed of BDD framework as well call external API’s and not able to create test cases for both due to “–disable-security-policy” option not available in plugin.
Thanks for the information; what is the bigger picture of what you are trying to do? Are you looking to speed up development of new code or bulk increase coverage or something else?
Any more information that can help me to resolve R013 error code because i dont have any idea about code. just create a test cases. Can you please help on this?
Hi,
R013 is an output code that lets you know why Diffblue Cover did not generate tests for a specific class. How many R013s are you seeing your project? Is it just a single instance or spread through out the project?
To resolve a R013 it will require some user input as Diffblue Cover needs help to construct your class. So I understand, are you able to tell me more what you mean by you don’t have any idea about the code. Do you mean you are not able to refactor the code or do you need some more guidance with the options linked in the docs?
Thanks, Thomas @ Diffblue
Hi,
The solution to this issue will be specific to your code and so I cannot make any suggestions with the current information as you are not able to share source code or log files. In order to help you further I will need more information, maybe you could provide some sample code that provides the same behaviour but you are able to share.
Thanks, Thomas
Thanks for the example code, this always helps when trying to reproduce something. I have created the classes in IntelliJ and run the Diffblue plugin to create tests. Everything was successful with the creation of three new test classes. I am running plugin Diffblue Cover Plugin version 2022.08.03.
For this simple example can you reply with the Diffblue plugin log file? I can then compare versions and anything else that might be different.
Yes we also able to create test cases for this sample code. But sometimes not able to create test cases for mocking classes and methods. Can you please provide any solution for this?
Because still some of the service classes we are not able to create test cases.
If we get something it will be great help for us.