Its called Irony
Irony (from the Ancient Greek εἰρωνεία eirōneía, meaning dissimulation or feigned ignorance)[1] is a rhetorical device, literary technique, or situation in which there is a sharp incongruity or discordance that goes beyond the simple and evident intention of words or actions. Ironic statements (verbal irony) often convey a meaning exactly opposite from their literal meaning. In ironic situations (situational irony), actions often have an effect exactly opposite from what is intended. The discordance of verbal irony is created as a means of communication (as in art or rhetoric). Descriptions or depictions of situational and dramatic ironies, whether in fiction or in non-fiction, serve a communicative function of sharpening or highlighting certain discordant features of reality.
Fromy my favourite source