Unable to use PowerMockRunner along with Assertj
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start by reproducing the reported interaction between PowerMockRunner, AssertJ, JUnit, and the minimal Backend/GUI scenario described in the issue. Verify whether Backend.m1() is intercepted when the GUI is initialized and whether its dependent methods are avoided; done means the static method remains mocked in the combined test class.
Written by the indexing model from the issue text.
Description
I started using Assertj for unit testing for GUI related code in my application. But I stumbled across an issue when I was trying to use PowerMockito.mockStatic() along with assertj in the same test class.
In my application, along with the swing related components initialization, I have some backend related code which is a static method, so I need to use PowerMockito.mockStatic() to mock those static method calls. But what actually happening is, it is not returning the mocked object instead it is calling the actual method without being mocked.
Due to company policy, I can't share the code, but this is the scenario I'm facing :
/*The actual code is similar to this representation */
class Backend
{
public static void m1()
{
// some lines which does registration and doesn't return any value
}
}
class GUI
{
// GUI LINES
Backend.m1(); //This is where code says error saying initialization error.
}
Actually the calling is being made to m1() and it m1() is calling other internal classes.
When i mock the class, it is not supposed to call the other methods dependent on m1(), which is not the case when im using assertj in my junit.
So i would like someone to look into the issue of using PowerMockRunner along with assertj.
- Dominant language
- Java
- Stars
- 121
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from assertj/assertj-swing
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
assertj/assertj-swing#279 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
assertj/assertj-swing#278 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
assertj/assertj-swing#276 · 1 comment ·
-
Update unit test to avoid deprecated `ExpectedException.none()` by using `Assert.assertThrows()` Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
assertj/assertj-swing#275 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
assertj/assertj-swing#277 · 1 comment ·
All issues in assertj/assertj-swing
Similar issues
-
area/plugin
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
kestra-io/plugin-kestra#190 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/rocketmq-dashboard#5064 ·