Forum Discussion

AutomatedMonkey's avatar
AutomatedMonkey
New Contributor
2 years ago

Anyone gotten ExtentReports 5 with spark reporter working via java bridge?

Trying to get Extent reports working, have java bridge pointing towards AdoptOpen JDK 11:

And my class path as follows:

And then the following code:

 

function TestProc()
{
  var path = "c:\\temp\\reporter.html";    
  var file = JavaClasses.java_io.File.newInstance(path);
  var extentReports = JavaClasses.com_aventstack_extentreports.ExtentReports;
  var status = JavaClasses.com_aventstack_extentreports.Status;  
  var report = extentReports.newInstance();
  var spark = JavaClasses.com_aventstack_extentreports_reporter.ExtentSparkReporter;
  spark = spark.newInstance(file);
  report.attachReporter_2(spark);
  var Test1 = report.createTest("Sample Test");
  var node = Test1.createNode("Sample Node");
  node.log(status.PASS, "Sample step description");
  report.flush();  
}

 

Its finding the classes and intellicomplete is suggesting the correct functions/methods for the classes, but attach reporter gives the error:


JavaScript runtime error.

java.lang.IllegalArgumentException: argument type mismatch

Error location:
Unit: "TestProject1\TestProject1\Script\Unit1"
Line: 10 Column: 10.

 

I'm not sure what I'm missing here, in Java you start a new instance of ExtentReports, then a new instance of sparkreporter, passing a path, and then attach the reporter to your instance of ExtentReports, but can't quite seem to figure out how to get this working. If anyone else has been successful is doing this, I'd really appreciate seeing your project classes and classpath setup, as well as your initial report setup.

 

I think root of the error is attachreporter_2 is expecting the object type to be com.aventstack.extentreports.observable, in java this seems to be inherited automatically normally, but I'm not sure why its having trouble seeing JavaClasses.com_aventstack_extentreports_reporter objects as the wrong type. 

No RepliesBe the first to reply