Not able to create test cases using diffblue intellij plugin

Facing below issue:-

Cover was unable to write any tests for the reasons listed below, but was able to write 1 partial tests to get you started.
Change what sort of tests Cover writes in Change Settings.
Partial tests written: 1
R011 - Sandboxing policy violation: 1

Hi @pooja_singhani

Thank you for raising this - are you able to share the source code, and the log file with us so we can see what could cause the R011 output code. The log file can be found following this page - Log file | Diffblue Docs
We also have some documentation around dealing with this output code which is worth looking at - Working with code R011 | Diffblue Docs

Kind regards,
Jane @ Diffblue

Not able to share logs and code. Any help ?

Hi @pooja_singhani

Without log files we are unable to provide any specific advice. However, I would recommend reading our documentation on this output code as there is good guidance on how to deal with this - see page; Working with code R011 | Diffblue Docs

Kind regards,
Jane @ Diffblue

Go through the diffblue docs for Sandbox issue. Also allow option in diffblue settings.
What need to mention in “Sandboxed Environment Options”. Can you please help on this?

If able to do any help please provide me for above query

Hi @pooja_singhani,

Our sandboxing policy protects you from a test that could break your system (e.g. a test that deletes files on your disk, calls an external API etc). We have disabled this test because it could be dangerous.

You should look at the test and if you think it is safe you can remove the @Disable annotation and let the test run.

Thanks

Matt @ Diffblue

But there is no @disable annotation in java class. can you please more elaborate on this? Any another way so that not disabled the test and create proper junit test cases

There is no Diffblue created test with the @disable annotation at all?

How many tests did Diffblue create? Your original message says that we created 1 partial test?

Thanks

Matt @ Diffblue

Yes create a partial test case but nothing is there is partial test cases. Just create below test case:-

void testcasename(){
// TODO: Complete this test.
// Reason: R011 Sandboxing policy violation.
// Diffblue Cover ran code in your project that tried
// to access JMX APIs.
// Diffblue Cover’s default sandboxing policy disallows this in order to prevent
// your code from damaging your system environment.
// See Output codes | Diffblue Docs to resolve this issue.
}

create like this

and declare null variable in it

so no coverage get if i run this test case

If any solution can you please update on this OR any other option let me know

Hi @pooja_singhani,

Thanks - so we didn’t write a test because we blocked access to JMX because it could have caused dangerous side effects. In this case we have therefore been unable to create the test so have given you the body of the test for you to complete.

Thanks

Matt @ Diffblue

Hi @pooja_singhani,

We have discussed internally how to help you with this - In the CLI version you can use the --disable-security-policy option to help in this situation User Manual | Diffblue Docs

Do you have access to the CLI version to try this? If not we can organise this for you

Kind Regards

Matt @ Diffblue

I don’t have access to CLI version. Please help on this.

Hi @pooja_singhani,

You can signup for a CLI trial license; this is available at Try Cover | Diffblue

To get started check out Getting Started with DCover CLI for Linux / macOS | Diffblue Docs and then you will be able to use the --disable-security-policy option

If you have already done a trial and the key has already expired then we can extend this for you

Please don’t hesitate to come back here with questions; we are always happy to help :slight_smile:

Thanks

Matt @ Diffblue

Free Trial | Diffblue_ga_1SWRVKPFMJMTY1OTMzMjY0MC4yMC4xLjE2NTkzMzI3NjYuMA…

this link is for CLI?

Because i download using below link:-

but not able to see any .exe for installer. Can you please help on this?

Hi @pooja_singhani

Yes, that is the correct link. We saw you had a trial previously so have extended it until 14/08/22 for you to try the CLI - I will email you directly.
Please let us know if you don’t receive my email, or have any further questions

Kind regards,

Jane @ Diffblue

dcover.bat --disable-security-policy

When i execute above command return

Unknown option: ‘–disable-security-policy’

Hi @pooja_singhani

Please run dcover create --disable-security-policy com.example.package.class in the root of the compiled module. Please replace com.example.package.class with the class you want to write tests for

Thanks

Matt @ Diffblue

One more thing i need to confirm once we disable “–disable-security-policy” using CLI
then we able to create test cases without CLI