How do I specify the file name and create the file to be used in a test?

How to specify the input rule, so that created object uses the provided file name? The generated test uses test.txt instead of provided value… The log is below.
Thanks,
Wes

================================================================================
= Creating tests for ‘com.h.base.config.ConvertDevToServerEditorDef.:(Ljava/io/File;)V’ using ‘SiM (!sp, !fnm, df, !ris)’

09:18:12.931 [INFO][analyzer-service:TimedExecutor-224][c.d.f.b.d.e] Using custom input rule: C:\java\tfa-java-services\DiffblueRules.yml:2:4-5:70 factory type==java.io.File && className=~.\Qcom.h.base.config.ConvertDevToServerEditorDef\E. => java.io.File.:(Ljava/lang/String;)V [src/test/resources/devActypeEditorDef.json]
09:18:15.595 [INFO][analyzer-service:TimedExecutor-224][c.d.fuzztest.a.d] Refinement loop done: 2 seeds, 2+0 new+accumulated tests, 0+2 tests+partial tests, 502/1000 its, 2.657s, 5.3ms/it
09:18:16.481 [INFO][analyzer-service:grpc-default-executor-2][c.d.fuzztest.d.q] Created 2 partial tests via ‘SiM (!sp, !fnm, df, !ris)’, 2/2, here is the last one:
09:18:16.530 [INFO][analyzer-service:grpc-default-executor-2][c.d.fuzztest.d.q] == begin partial test ==
09:18:16.531 [INFO][analyzer-service:grpc-default-executor-2][c.d.fuzztest.d.q] Test:
package com.h.base.config;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import javax.xml.parsers.ParserConfigurationException;
import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;

public class ConvertDevToServerEditorDefTest {
/**

  • Method under test: {@link ConvertDevToServerEditorDef#ConvertDevToServerEditorDef(File)}
    */
    @Test
    @Ignore(“TODO: Complete this test”)
    public void testConstructor() throws IOException, ParserConfigurationException, SAXException {
    // Arrange
    File dbSchemaFile = Paths.get(System.getProperty(“java.io.tmpdir”), “test.txt”).toFile();

    // Act
    new ConvertDevToServerEditorDef(dbSchemaFile);
    }
    }

09:18:16.533 [INFO][analyzer-service:grpc-default-executor-2][c.d.fuzztest.d.q] Reason to be partial:
com.diffblue.cover.exception.limitation.NoNonThrowingInputsException: No generated test that does not throw a trivial exception: org.xml.sax.SAXParseException
at com.diffblue.fuzztest.a.d.a(SourceFile:383)
at com.diffblue.fuzztest.a.d.a(SourceFile:2685)
at com.diffblue.fuzztest.a.d.a(SourceFile:223)
at com.diffblue.fuzztest.d.p.a(SourceFile:1268)
at com.diffblue.fuzztest.d.t.a(SourceFile:84)
at com.diffblue.fuzztest.d.s.a(SourceFile:45)
at com.diffblue.fuzztest.d.b.k(SourceFile:321)
at com.diffblue.cover.sandbox.execution.WorkerThread.lambda$callWorkerThread$3(SourceFile:134)
at com.diffblue.cover.sandbox.execution.WorkerThread.run(SourceFile:207)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:261)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)
at com.h.base.config.ConvertDevToServerEditorDef.initDbSchema(ConvertDevToServerEditorDef.java:83)
at com.h.base.config.ConvertDevToServerEditorDef.(ConvertDevToServerEditorDef.java:76)
at jdk.internal.reflect.GeneratedConstructorAccessor25.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.diffblue.tir.a.h.a(SourceFile:75)
at com.diffblue.tir.a.a.c.a(SourceFile:656)
at com.diffblue.tir.a.f.b(SourceFile:411)
at com.diffblue.tir.a.f.a(SourceFile:79)
at com.diffblue.tir.d.d.a(SourceFile:25)
at com.diffblue.tir.a.g.a(SourceFile:214)
at com.diffblue.tir.a.g.a(SourceFile:148)
at com.diffblue.fuzztest.a.d.a(SourceFile:754)
at com.diffblue.cover.sandbox.execution.TimedCallableExecutor$CallableFuture.executeTask(SourceFile:27)
at com.diffblue.cover.sandbox.execution.TimedExecutor$TaskQueueRunner.run(SourceFile:66)
… 1 common frames omitted
09:18:16.552 [INFO][analyzer-service:grpc-default-executor-2][c.d.fuzztest.d.q] == end partial test ==
09:18:16.552 [INFO][analyzer-service:grpc-default-executor-2][c.d.fuzztest.d.q] All 2 subs either threw or created only partial tests; returning the 2 partial tests created by ‘SiM (!sp, fnm, df, !ris)’
09:18:16.554 [INFO][analyzer-service:TimedExecutor-443][c.d.fuzztest.d.b]

From the logs you’ve shared it seems that you have a rule configured and being applied, but clearly it’s not resulting in a good test which is disappointing.

One thing strikes me as odd: the exceptions thrown are org.xml.sax.SAXException implying that the code is expecting a .xml file but the file referenced in your rule ends in .json, could it be that your rule is referring to the wrong file for use with this method?

Thanks,

Rob

If the test was generated correctly using the file name provided by the rule and it was still throwing the exception, then we could focus on the validity of the file name… Am I making sense?
If the rule syntax is correct, and this is a bug, what would be the expected ETA for a fix? What is the turnaround to fix tickets for the enterprise license holders?
Thanks,
Wes

Hi @wes

Thanks for your message - I will let Rob respond on the technical question but I can answer regarding prioritisation of defects and timelines.

Defects are ranked by severity (1-4) which is based on the impact to the quantity and quality of the tests we produce. We release every 2 weeks with the highest priority issues resolved soonest, severity 1 issues being prioritised to be fixed immediately.

Thanks

Matt @ Diffblue

Hi @wes

I think it is worth making sure that the file name & content are correct for what the ConvertDevToServerEditorDef(..) constructor needs if you can.

Diffblue Cover is driven by coverage, and so custom (or other) inputs that don’t increase the coverage will get discarded. My guess is that here the custom path specified refers to a non-existent file and Cover has moved on to trying further files, eventually hitting on ${java.io.tmpdir}/test.txt which happens to exist and ends up producing slightly more coverage before throwing the SAXException.

My guess could be wrong though, so if you think this is a bug, would you be able to share a cut down example project with us demonstrating the problem? If we’re able to reproduce the failure then our ability to understand and resolve it is much improved!

Thanks,

Rob

Hi @wes

Just thought I’d check in and see if you’d been able to make any progress? If you’re still having problems then I’d love to get a better idea how to reproduce it and get an understanding of what’s going on.

Thanks,

Rob

Hi Rob,

I created the unit test that utilizes my file rule and it worked exactly how it was supposed. Not sure yet why my file name rule did not work on the ‘real’ class …

Then, I got diverted with other issues. I will have to get back to it.

Thanks,

Wes

That’s fine - I’ll keep an eye out for messages for if/when you get back to it.

Thanks,

Rob