In Java, is there a generic way to embed the code of a method in a log by any means? I am working in Cucumber and altough its tending towards (or is?) bad practice, the compliance department wants to see the assertions behind a "Then" statement printed out in the report (they cant access the source code). Writing to a log is the easy part, but how can i read everything in a method behind a "@Then" in a generic way?
So just to give you an idea of an example method:
@Then("^my profile information is retrieved with success")
public void validateProfileInformation() {
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
if (this){
x = y;
}
}
What needs to be written in the log:
SOME HEADER TEXT
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
assertThat(..).isEqualTo(..);
**Optionally:**
if (this){
x = y;
}
So i really need the unexecuted code, dont need the outcome. Preferably like a generic method or interceptor, so that it can be applied accross the project, rather than having to add it to each method. A push in the right direction would be appreciated.
Aucun commentaire:
Enregistrer un commentaire