assertj / assertj/assertj-swing

Unable to use PowerMockRunner along with Assertj

Open
#225 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
121
Forks
52
PR merge metrics
No merged PRs in 30d

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.