assertj / assertj/assertj-swing
Unable to use PowerMockRunner along with Assertj
- Lingua principale
- Java
- Stelle
- 121
- Fork
- 52
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia riproducendo l’interazione tra PowerMockRunner, AssertJ, JUnit e lo scenario minimo Backend/GUI descritto nell’issue. Verifica se Backend.m1() viene intercettato quando la GUI viene inizializzata e se i relativi metodi dipendenti vengono evitati; il lavoro è completato quando il metodo statico rimane mockato nella classe di test combinata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- desktop, testing
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100