[Scala] I have a class someClass with a function A in which I use log4j2 for logging.
class someClass {
def A ={
//smt
logger.warn("oups")
}
}
In my unit tests someClassTest, I want to collect what A logs and assert the message content.
class someClassTest {
it("should log warning") {
//trigger A()
//collect logs
val logs //contain logs
assert(logs(0).contains("oups"))
}
}
Theatrically, I should create a custom Appender (extending the AbstractAppender) and collect the logs in a list for example, but I cannot do that, or more like idk how to do that. Is there other ways to assert the logs ? or how to create that custom Appender?
Thank yall