jmborer edited a comment on issue #1042: Update TestOutputListenerProvider.java 
to fix [NETBEANS-635] 
URL: 
https://github.com/apache/incubator-netbeans/pull/1042#issuecomment-442730543
 
 
   I’ll try to extend the existing unit test, but the problem is that currently 
the reports path is deducted from the project context, because the surefire 
plugin no longer logs the path on the console (I have filed a change request 
for that on the surefire Jira). It is very difficult to create a unit test for 
this feature without a mocking framework as you see below:
   
   ```
   try {
      Object defaultValue = 
PluginPropertyUtils.createEvaluator(visitor.getContext().getCurrentProject())
                           
.evaluate("${project.build.directory}/surefire-reports");
      if (defaultValue instanceof String) {
         outputDir = (String) defaultValue;
          // don't want to create link on the surefire line
         // visitor.setOutputListener(new TestOutputListener(runningTestClass, 
outputDir), true);
      }
      return;
   } catch (ExpressionEvaluationException ex) {
      Exceptions.printStackTrace(ex);
   }
   ```
   The PluginPropertyUtils.createEvaluator expects a NbMavenProjectImpl and it 
is very difficult to create a fake Maven version of it, because it is not an 
interface and the constructor of the class NbMavenProjectImpl or even the 
factory require also not easily fakables objects:
   
   `NbMavenProjectImpl(FileObject folder, FileObject projectFO, ProjectState 
projectState)`
   
   I would have loved to be able to use Mockito in this case, but because of my 
lack of time, I didn’t have time to check if it is available and if I have the 
« right » to add such kind of stuff to the NB build system.
   If the NB build would have been Maven based, this would could be done more 
easily, but I am not even sure this would have properly worked.
   
   Therefore I can write a unit test that will show that the expressions work 
with "logging" enabled or not, but I won't be able unit test the path fallback 
based on the MavenProjectImpl...
   
   If you have an idea how to Mock the project path in this context, I would 
really appreciate your help here.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to