Changing the way a JUnit test description is generated (SMProxy.myName)

Hi,

I'm trying to change the way test descriptions / node names are generated when running a certain JUnit test. The reason is that we use JBehave which maps BDD type plain-text stories to JUnit tests. Unfortunately it looks like when the test node names are generated they expect the descriptions to be FQNs so everything before the last period is removed.

Example:

JUnit tests:

JBehave tests:

What the JBehave tests look like in Eclipse:

Because this is a relatively unique way of running JUnit I assumed it would be quicker to modify the code / plugin myself instead of creating an improvement issue.

Unfortunately I was unable to find the place where to change the behavior. It looks like the actual conversion is done somewhere in com.intellij.execution.testframework.sm.runner.OutputLineSplitter which would mean it's outside the scope of the JUnit plugin. Using the Ultimate version we would need to find a way to change the JUnit plugin.

Do you have any advice how to approach this? I would need to add some custom logic to make sure that "regular" JUnit tests names are generated properly and that JBehave tests look the way we want.

 

Thank you.

1
6 comments

Hi Simon,

the test results are prepended with class names because the parent name is not the class name. The logic is encapsulated here com.intellij.execution.testframework.sm.runner.SMTestProxy#getPresentableName. It looks like that the change can be done inside core code only. Could you please fire an issue with the sample project to reproduce?

Thanks,

Anna

1
Avatar
Permanently deleted user

Hi Anna,

thanks for the quick reply.

I'm not sure I understand. Do you want me to create a new issue on your tracker with test code for you to execute? I would gladly do that but that will take me some time because I have to wrap it all in one folder and create an example that doesn't contain any confidential code.

0

Yes, I suggest to create an issue with sample code. You can remove all logic and it's enough to have one hierarchy level so should be much easier than to fix the plugin. 

Anna

0
Avatar
Permanently deleted user

Hi Anna,

 

I found an issue already assigned to you that describes the problem: https://youtrack.jetbrains.com/issue/IDEA-151363

I added example code and some screenshots. Basically, if you would refactor the code so that the presentable name for a test step could be provided by the testing framework plugin I'd be able to provide a fix in form of a plugin.

Thank you.

0

Yes, I remember the issue that's why asked you to submit the sample. The suggested solution is not acceptable because the place works for all tests frameworks and the issue is still open because I don't have a general solution fit for everyone.

0
Avatar
Permanently deleted user

Thanks for replying.I know it's not a solution; that's why I'd be happy if the code would be refactored for me to implement a fix that works in our company without having to manually replace class files in JARs. That's a bit hacky ;-)

0

Please sign in to leave a comment.