-
Notifications
You must be signed in to change notification settings - Fork 65
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
Throw specific exceptions based on the method under testFeature/zfj/add exception on actual #29
Merged
yaronyam
merged 23 commits into
wrdv:master
from
huangliang992:feature/zfj/add-exception-on-actual
Apr 11, 2024
Merged
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8d068d4
Throw specific exceptions based on the method under test
zhangfj88 7cfcfc6
Throw specific exceptions based on the method under test
zhangfj88 038ba02
Merge pull request #3 from zhangfj88/add-exception-on-actual
zhangfj88 e17994d
Throw specific exceptions based on the method under test
zhangfj88 8cba2c5
Throw specific exceptions based on the method under test
zhangfj88 3cb7ef0
Throw specific exceptions based on the method under test
zhangfj88 1671e0b
Add a UI setting as "declare specific test method thrown exception ty…
zhangfj88 86a47ab
Throw specific exceptions based on the method and configuration
zhangfj88 0579e4f
Throw specific exceptions based on the method and configuration
zhangfj88 f92797c
Merge branch 'master' into add-exception-on-actual
zhangfj88 ce60478
Throw specific exceptions based on the method and configuration
zhangfj88 3385ccf
Throw specific exceptions based on the method and configuration
zhangfj88 3dc4ae1
Merge pull request #7 from zhangfj88/add-exception-on-actual
zhangfj88 d1a7e97
Throw specific exceptions based on the method and configuration
zhangfj88 f0e8d73
Throw specific exceptions based on the method and configuration
zhangfj88 24f4d08
Merge pull request #8 from zhangfj88/add-exception-on-actual
zhangfj88 30e421a
Throw specific exceptions based on the method and configuration
zhangfj88 618b035
Throw specific exceptions based on the method and configuration--add …
zhangfj88 69343c7
Merge pull request #9 from zhangfj88/add-exception-on-actual
zhangfj88 43f6a16
Throw specific exceptions based on the method and configuration--add …
zhangfj88 558874e
Merge pull request #10 from zhangfj88/add-exception-on-actual
zhangfj88 22c3d16
Throw specific exceptions based on the method and configuration--add …
zhangfj88 b262555
Merge pull request #11 from zhangfj88/add-exception-on-actual
zhangfj88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ator/declareSpecificTestMethodThrownExceptionTypes/src/com/example/services/impl/Foo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.services.impl; | ||
|
||
import com.example.foes.Fire; | ||
|
||
public class Foo | ||
{ | ||
public Fire hasException(Fire tee) throws Exception { | ||
return tee; | ||
} | ||
public Fire hasNoException(Fire tee) { | ||
return tee; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...declareSpecificTestMethodThrownExceptionTypes/test/com/example/services/impl/FooTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.services.impl; | ||
|
||
import com.example.foes.Fire; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* created by TestMe integration test on MMXVI | ||
*/ | ||
public class FooTest { | ||
Foo foo = new Foo(); | ||
|
||
@Test | ||
public void testHasException() throws Exception { | ||
Fire result = foo.hasException(new Fire()); | ||
Assert.assertEquals(new Fire(), result); | ||
} | ||
|
||
@Test | ||
public void testHasNoException() { | ||
Fire result = foo.hasNoException(new Fire()); | ||
Assert.assertEquals(new Fire(), result); | ||
} | ||
} | ||
|
||
//Generated with love by TestMe :) Please raise issues & feature requests at: https://weirddev.com/forum#!/testme |
23 changes: 23 additions & 0 deletions
23
...pecificTestMethodThrownExceptionTypes/testGroovy/com/example/services/impl/FooTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.example.services.impl | ||
|
||
import com.example.foes.Fire | ||
import org.junit.Test | ||
|
||
/** created by TestMe integration test on MMXVI */ | ||
class FooTest { | ||
Foo foo = new Foo() | ||
|
||
@Test | ||
void testHasException() { | ||
Fire result = foo.hasException(new Fire()) | ||
assert result == new Fire() | ||
} | ||
|
||
@Test | ||
void testHasNoException() { | ||
Fire result = foo.hasNoException(new Fire()) | ||
assert result == new Fire() | ||
} | ||
} | ||
|
||
//Generated with love by TestMe :) Please raise issues & feature requests at: https://weirddev.com/forum#!/testme |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in case non found -
throwsException
would be empty string rather then null, if so please replace withreturn throwsException.isEmpty() ? "Exception" : throwsException;
would also be good to change/add integration test to throw a more specific exception (i.e.
java.io.IOException
) rather thenException
in order to verify mapping logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,Let me modify the code then submit it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to case 3,
so ,you prefer to throwing Exception in case 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean...thanks for elaborating
Ok, lets keep this logic as you suggest. Would like to refine the UI text to better express this into:
"Declare exceptions thrown by tested class" - so it would suggest that only if tested class actually declares exceptions - so will the test method.
Furthermore please do a small refactor... I find that mutating throwsExceptions variable and using it to transitively reflect throwSpecificExceptionTypes state - a bit confusing.
please use this alternative:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for optimizing the code. I am modifying the code and then submit.