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

Pharo freezes when clicking on failed test link in Test Runner #41

Open
yujihamaguchi opened this issue Apr 12, 2024 · 4 comments
Open

Comments

@yujihamaguchi
Copy link

yujihamaguchi commented Apr 12, 2024

Environment

  • OS: Ubuntu 22.04
  • Pharo 11.0 - 64 bit (stable)

Issue Details

When a test fails and I click on the failed test link in the Test Runner, the Pharo environment freezes. I have attached a screenshot of the freeze.
Screenshot from 2024-04-13 07-17-46
The terminal from which Pharo was launched shows the following log with a repeating pattern at lines 9 to 16:

     1	SpecOfFailed: a Mock(component) never received messageB
     2	SpecOfExpectedMessageValidationFailure(SpecOfValidationFailure)>>raise
     3	SpecOfShouldExpression>>evaluateWith:
     4	SpecOfShouldExpression>>evaluateWith:forMockBehaviour:
     5	MockValidator>>processTransformedMessageSend:by:
     6	MockValidator(MockHelperRole)>>processMessageSend:by:
     7	MockBehaviour>>send:to:
     8	MockBehaviour(GHGhostBehaviour)>>intercept:to:
     9	SpecOfFailed: a Mock(component) never received class
    10	SpecOfExpectedMessageValidationFailure(SpecOfValidationFailure)>>raise
    11	SpecOfShouldExpression>>evaluateWith:
    12	SpecOfShouldExpression>>evaluateWith:forMockBehaviour:
    13	MockValidator>>processTransformedMessageSend:by:
    14	MockValidator(MockHelperRole)>>processMessageSend:by:
    15	MockBehaviour>>send:to:
    16	MockBehaviour(GHGhostBehaviour)>>intercept:to:

Target and Test Code

The code for the MyClazz class being tested and the MyClazzTest class is as follows:

Object subclass: #MyClazz
	instanceVariableNames: ''
	classVariableNames: ''
	package: 'My-Package'

MyClazz class>>component: aComponent

	^ self new setComponent: aComponent

MyClazz>>messageA
	"do nothing"

MyClazz>>setComponent: aComponent

	component := aComponent.
	^ self
TestCase subclass: #MyClazzTest
	instanceVariableNames: ''
	classVariableNames: ''
	package: 'My-Package-Tests'

MyClazzTest>>testMessageA

	| target component |
	"Arrange"
	component := Mock new.
	component stub messageB willReturnYourself.
	target := MyClazz component: component.
	
	"Act"
	target messageA.

	"Assert"
	component should receive messageB

Expected Behavior

The expected behavior is that when a test fails, the Pharo environment should not freeze, allowing the details of the failure to be viewed without issue.

@dionisiydk
Copy link
Owner

Thanks for the report.
Something was changed around how a debugger interacts with objects from the context where mock objects can be visible.
I will try to find a fix

@yujihamaguchi
Copy link
Author

Thank you for your response.

I wanted to share that the stable version of Pharo has recently been updated to version 12, and I have observed the same issue occurring in this version as well.

Thank you for looking into this.

Best regards,

@dionisiydk
Copy link
Owner

No real fix yet. But to bypass the issue you can redefine a set of messages the mock objects allowed to override:
TestExecutionEnvironment>>currentMetaLevelForMocks
^GHMetaLevel standard

Normally during the test you can stub arbitrary messages even those which are used by IDE itself (like printString for inspector/debugger). With #standard meta level these messages will not be possible to stub during the test. But usually it is really needed.

@dionisiydk
Copy link
Owner

Hm, while I wrote my comment my image with debugger became hanged. So no workaround yet.

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