SDK module unit testing

SDK module unit testing

matthieu_m1
Not applicable
14 Views
4 Replies
Message 1 of 5

SDK module unit testing

matthieu_m1
Not applicable

[ FlexSim 19.0.0 ]

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 !

0 Likes
Accepted solutions (1)
15 Views
4 Replies
Replies (4)
Message 2 of 5

allister_wilson
Not applicable

just bringing this to the attention of @jordan.johnson

0 Likes
Message 3 of 5

JordanLJohnson
Autodesk
Autodesk
Accepted solution

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:

17313-additionalincludes.png

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.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 4 of 5

matthieu_m1
Not applicable

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 :

17337-flexsim-module-tree.png

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
Message 5 of 5

JordanLJohnson
Autodesk
Autodesk

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.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes