Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert does not play nice with properties #209

Closed
slabarque opened this issue Mar 20, 2023 · 2 comments
Closed

Assert does not play nice with properties #209

slabarque opened this issue Mar 20, 2023 · 2 comments

Comments

@slabarque
Copy link

slabarque commented Mar 20, 2023

Describe the bug
Asserting the expected value of a property makes TcXaeShell crash and triggers a windows Blue-Screen-Of-Death causing a full pc reboot.

To Reproduce
Follow the introduction user guide. Then add a property to FB_Sum and assert it's value in a test.

AssertEquals(Expected := ExpectedProp,
             Actual := Sum.Prop,
             Message := 'Testing prop');	

Expected behavior
No crash.

Software versions
Which version of the applicable software did you use?

  • TcUnit library: 1.2.0.0
  • TcXaeShell Version 15.0.28307.1913 D15.9
TcProjectCompare   1.0
Visual Studio Integrated Version of TcProjectCompare

TcTargetBrowserPackage Extension   1.0
TcTargetBrowserPackage Visual Studio Extension Detailed Info

TcXaeDebuggerLiveWatch   1.0
TwinCAT XAE Live Watch Tool Window

TcXaeHelper   4024.40.0.0
Info

TcXaeModules   4024.40.0.0
TwinCAT TMC Editor, TwinCAT TMC Code Generator

TcXaeShell   1.7.1
TwinCAT XAE Shell customization

TcXaeStartPage   1.13
Beckhoff Start Page for TwinCAT XAE

TwinCAT 3 AML Data Exchange    1.10.0.0
Provides import and export of AutomationML for TwinCAT

TwinCAT Bode Plot   3.4.3147.12
Integration package for TwinCAT Bode Plot components

TwinCAT Filter Designer   3.4.3147.12
Integration package for TwinCAT Filter Designer components

TwinCAT Measurement   3.4.3147.12
This package contains the project system for TwinCAT Measurement projects.

TwinCAT Scope   3.4.3147.12
Integration package for TwinCAT Scope components

TwinCAT XAE Base   3.1.0.0
The TwinCAT XAE Base extension provides the basic project structure for TwinCAT projects.

TwinCAT XAE EventLogger   4024.40.0.0
The TwinCAT XAE Eventlogger extension provides the capability of monitoring events sent through the TwinCAT 3 Eventlogger of a target system.

TwinCAT XAE PLC   3.1.0.0
PLC Environment

Run environment
Soft PLC

Additional context
I created a repo that demonstrates the issue. The fix is simple, work with an in between variable.

@sagatowski
Copy link
Member

sagatowski commented Nov 23, 2023

I can confirm that you get a BSOD with TcUnit 1.2.0.0.
It's a more graceful crash using the current master of TcUnit (1.2.1.0), but it still crashes.
(both tests running with latest TwinCAT 3.1.4024.53).

Can't quite figure out what the problem is, however...
As you correctly say, one fix is to use an inbetween variable, but another solution is to use Assert using the primitive type that you are asserting.
Another alternative is to use assertequals for the correct primitive type. I noticed that you are using AssertEquals(). If you use AssertEquals_BOOL() instead, it works just fine on properties.
I generally don't recommend to use AssertEquals anyway, as it doesn't provide as good assertions-information as if you use the primitive type assertions instead.

sagatowski added a commit that referenced this issue Nov 24, 2023
…cumentation.

Updated main README with additions to contributions.
Fixed minor issues in the documentation.
@sagatowski
Copy link
Member

@slabarque

This is according to the compiler. I've documented it in the FAQ here:
https://tcunit.org/#/faq?id=_13-assertequalsany-on-properties-makes-my-development-environment-crash-why

As this is not a limitation in TcUnit, I will close this ticket now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants