​​
Hi all,

One of my long time frustrations with MockConfigRule was the bloating it
caused by forcing you to mock each and every ConfigValue you may use, when
more often than not you don't really care about the value but just was your
test to not fail with a NullPointerException.

I've recently merged a series of patches to address this and return the
default value for any ConfigValues that is not explicitly specified. In
other words, this aligns MockConfigRule's behavior with the production code
- if a value is specified, return it, and if not, return the default from
the annotation.

This change has no effect on values you explicitly mock, and if you
particularly need a certain ConfigValues to return null, you may state so
implicitly, either inline when you construct the Rule:

@Rule
public static MockConfigRule mcr = new
MockConfigRule(mockConfig(ConfigValues.SomeValue, null));

Or later on when you need it:

@Test
public void someTest() {
    mcr.mockConfigValue(ConfigValues.SomeOtherValue, null);
}

Additional details can be found on the website:
http://www.ovirt.org/develop/dev-process/unit-testing-utilities/mockconfigrule/

-Allon
_______________________________________________
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel

Reply via email to