Skip to main content

on my constructor, I put a checker if this feature is available or not, using prefetchable.
 

public ModelTypeMaint()
{
Helpers.PreferenceHelper.CheckFeatures();
}

 

Now, I have tried to run a unit test on this particular graph, unfortunately even though I’ve implemented a mock setup, It still reads the Prefetchable checker.

How do I bypass the prefetchable on the constructor?

Unit Test Code

private ModelTypeMaint PrepareGraph()
{
SetupEnableDisable<ModelTypeMaint>();
var graph = PXGraph.CreateInstance<ModelTypeMaint>();
return graph;
}

rFact]
public void Test_Description_ValidLength()
{
ModelTypeMaint graph = PrepareGraph();

ModelType type = (ModelType)graph.Cachesctypeof(ModelType)].Insert(new ModelType
{
ModelCD = "UT00001",
Description = "Model Type: UNIT 00001"
});

Assert.InRange(type.Description.Length, 5, 255);
}

 

Thank you.

Hi @igalm15, I don’t think we can bypass the constructor code.

If this is your custom Graph file, (ModelTypeMaint), just simply comment that particular code and perform the unit testing.

You can also do this by having a setup screen with a checkbox field “Check Features”, based on this flag configuration, it can skip the constructor code.

 

Hope this helps!!


Hi @igalm15, I don’t think we can bypass the constructor code.

If this is your custom Graph file, (ModelTypeMaint), just simply comment that particular code and perform the unit testing.

You can also do this by having a setup screen with a checkbox field “Check Features”, based on this flag configuration, it can skip the constructor code.

 

Hope this helps!!

 

Hello @Naveen B , Thank you for your input. I was able to do the testing by commenting the checker on my constructor. But I’ll try your second suggestion, I’ll also make a test that will check the Check Feature setup should be checked. :) 

Again, thank you.


Reply