I try without success to define a Maven property for a f-m-p test case using JMockit. I use Deencapsulation.invoke to call the method "addProperty" and set a value but when it is call later in my code, the ojbect is null
@RunWith(JMockit.class)
public class SpringBootGeneratorServerPortTest {
@Mocked
private GeneratorContext context;
@Mocked
private MavenProject project;
@Mocked
private Build build;
@Mocked
private ModelBase model;
private GeneratorContext createGeneratorWithMavenPropertiesContext() throws Exception {
new Expectations() {{
context.getProject(); result = project;
project.getBuild(); result = build;
String tempDir = Files.createTempDirectory("springboot-test-project").toFile().getAbsolutePath();
build.getDirectory(); result = tempDir;
build.getOutputDirectory(); result = tempDir;
// Pass the property to the maven model
Deencapsulation.invoke(model,"addProperty","server.port","7777");
}};
return context;
}