question

Matthieu M avatar image
0 Likes"
Matthieu M asked Jordan Johnson commented

SDK module unit testing

Hi,

We recently started to develop modules for our needs.
Now, we would like to execute unit tests on our code.
We tried to methods to do so :

- We tried to create a tests sub-project
- We tried to create tests classes next to the logic

In both cases we couldn't get a satisfying result..
In the first case, we just couldn't include "FlexsimDefs.h" in the test's subproject.
In the second one, each test fails with this only error message "Message: Failed to set up the execution context to run the test".

Could you please explain us how to do ?

Thanks !

FlexSim 19.0.0
module sdkc++tests
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Allister Wilson avatar image Allister Wilson commented ·

just bringing this to the attention of @jordan.johnson

0 Likes 0 ·

1 Answer

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Jordan Johnson commented

I would probably keep trying the sub project route. As for not being able to include FlexsimDefs.h, You probably need to configure the project to include the flexsimcontent directory. In Visual Studio, you can right-click on a project in the solution explorer, and add additional include directories (places the compiler looks for header files). The default module project has this setting:

If you add the same settings to the test project, I think that should solve the #include issue. You may also need to link to flexsimcontent.lib and flexsim.lib. You can look at how the default project links, and do the same for the test project.

Let me know how that goes.


· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Matthieu M avatar image Matthieu M commented ·

Hi @Allister Wilson and @jordan.johnson, thank you for your quick answer !

Well, I think that actually, that's some kind of circular include issue.

Let me explain you with the module structure :



As you can see ClassTest.h tries to follow Class.h includes and searches for a FlexsimDefs.h in its own folder which obviously fails.

The "#pragma once" directive is set in both headers files and includes directories are correctly set in both projects.

I just can't figure out why it fails...

I can share you the project if you need it.

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Matthieu M commented ·

If you can share the project, that would probably help the most. I might not be able to get to it today, but I think I can in the next few days.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.