You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When converting TestNG tests the argument order in org.testng.Assert#assertEquals does not match the argument order in org.junit.jupiter.api.Assertions. I.e. in TestNG the argument order is (actual, expected, [message]), but in JUnit5 the argument order is (expected, actual, [message]).
So there are two problems:
The plugin tries to move the message argument from first to last, which is not needed at all if the original assertion uses TestNG assertions.
The plugin does not swap order of actual and expected arguments, which leads to quite misleading error messages if the assertion fails.
Describe the solution you'd like
If the original assertEquals invocation references the org.testng.Assert class the plugin should:
Not try to move the message to the last parameter (it is already there).
Swap order of the first and second argument.
Replace TestNG imports with corresponding JUnit5 imports
Note that the plugin currently does method matching on method name only, i.e. it does the conversion of all invocations of methods with name assertEquals, regardless of which class that declared the assertEquals method.
Describe alternatives you've considered
Manual argument reordering (extremely tedious for large code bases).
Building another plugin for TestNG -> JUnit5 conversion
Additional context
TestNG also has a org.testng.AssertJUnit. Invocations to that class should be treated just like invocations to JUnit4 Assert. I think this alread woks today (except that the import statement is not replaced).
I do understand that converting TestNG to JUnit5 might be a bit out of scope (given the plugin name), but I still wanted to suggest this feature. I would really appreciate your feedback on this suggestion, I should be able to contribute a PR shortly if you think the feature fits in your plugin.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When converting TestNG tests the argument order in
org.testng.Assert#assertEquals
does not match the argument order inorg.junit.jupiter.api.Assertions
. I.e. in TestNG the argument order is (actual
,expected
, [message
]), but in JUnit5 the argument order is (expected
,actual
, [message
]).So there are two problems:
actual
andexpected
arguments, which leads to quite misleading error messages if the assertion fails.Describe the solution you'd like
If the original assertEquals invocation references the
org.testng.Assert
class the plugin should:E.g. this test:
Should be converted to:
Note that the plugin currently does method matching on method name only, i.e. it does the conversion of all invocations of methods with name
assertEquals
, regardless of which class that declared theassertEquals
method.Describe alternatives you've considered
Additional context
TestNG also has a
org.testng.AssertJUnit
. Invocations to that class should be treated just like invocations to JUnit4 Assert. I think this alread woks today (except that the import statement is not replaced).I do understand that converting TestNG to JUnit5 might be a bit out of scope (given the plugin name), but I still wanted to suggest this feature. I would really appreciate your feedback on this suggestion, I should be able to contribute a PR shortly if you think the feature fits in your plugin.
The text was updated successfully, but these errors were encountered: