Render chart in Unit Tests

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Moderator: Queue Moderators

Post Reply
ezray3
Posts: 9
Joined: Sun Nov 11, 2018 9:41 am

Render chart in Unit Tests

Post by ezray3 » Wed Feb 20, 2019 7:48 am

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

ArctionKestutis
Posts: 549
Joined: Mon Mar 14, 2016 9:22 am

Re: Render chart in Unit Tests

Post by ArctionKestutis » Wed Feb 20, 2019 1:41 pm

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.

ezray3
Posts: 9
Joined: Sun Nov 11, 2018 9:41 am

Re: Render chart in Unit Tests

Post by ezray3 » Wed Feb 20, 2019 7:33 pm

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.

ArctionKestutis
Posts: 549
Joined: Mon Mar 14, 2016 9:22 am

Re: Render chart in Unit Tests

Post by ArctionKestutis » Thu Feb 21, 2019 7:41 am

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.

Post Reply