Page 1 of 1

Render chart in Unit Tests

Posted: Wed Feb 20, 2019 7:48 am
by ezray3
Hi,

My code create image of a chart in Headless mode.

Is it possible to write unit tests that run that code?

I had no success with that. it just not rendering when running in unit tests context...
It works great when running the app.

Thanks

Re: Render chart in Unit Tests

Posted: Wed Feb 20, 2019 1:41 pm
by ArctionKestutis
Hi,

Yes it is possible to write Unit test for Headless Mode LightningChart. We have written several of those ourselves and usually they function normally.
I do noticed some unexpected behavior, which could be due to Message loop functioning differently in UnitTest environment or there is some error in LightningChart.
In order to see which is the case, we may need to inspect your Unit test. Could you send your test to our Support email?
It will interesting to know how you are testing rendering as well?

In same cases, it may help if you call Series.InvalidateData() after adding data.

Hope this helps.
All the best.

Re: Render chart in Unit Tests

Posted: Wed Feb 20, 2019 7:33 pm
by ezray3
I'm testing a module that uses LightningChart to render charts as images and renders those images on a PDF report.
I'll see what I can send to you.

We don't really have an idea how to test the image content itself.
We thought we can test only the generation of the file with correct name, and that data was subscribed etc...
Do you have a way to test a rendered PDF document?

Thanks.

Re: Render chart in Unit Tests

Posted: Thu Feb 21, 2019 7:41 am
by ArctionKestutis
LightningChart could be exported/printed as image (raster or vector format) only. Therefore, part of PDF rendering is not part of LightningChart - it must be some third-party library. Ok, there is option to capture to byte-array or send directly to default printer, but I believe you not using those.

All the best.