I have a "negativ test" case, which must produce an error. So the excpected behaviour is to find in the Log an "ERROR:".
Is it possible to parameterize the Log Scan in a way, that finding "ERROR:" will cause a "passed" entry in the file "log4sasunit_asserts.log"?
Thank you very much.
Kind Regards
Albert Meyn
W&W Informatik GmbH
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.
This email may contain confidential and/or privileged information. If you are not the intended recipient (or have received this email in error) please notify the sender immediately and destroy this email. Any unauthorized copying, disclosure or distribution of the material in this email is strictly forbidden.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2024-02-12
Dear All,
at the end of a test case the log is automatically scanned for "ERROR:" I do not see a possibility to parameterize this log scan.
For a "negative test" I inject an error. So the expectation is, that the error in the log shoud be reported as
OK~001~1~1~assertLog~0~0#0~0#0~assertLog: assert passed.
Actually it is reported as:
ERROR~001~1~1~assertLog~2~0#0~3#0~assertLog failed:
Do I have the possibilty to change this behaviour?
Thank you very much.
Albert Meyn
W&W Informatik GmbH
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes it is possible to parameterize the logscan.
By design SASUnit adds a log scan at the end of the scenario. This happens when no log scan was implemented by the user.
Your problem can be solved by an explicit call to the macro assertLog.
Here you can specify then number of expected errors and warnings in the log (parameter i_errors and i_warnings.
As an example:
%assertLog(i_errors=1);
To make sure that you allow the expected error only, you can add a call to assertLogMsg:
%assertLogMsg(i_logmsg=<ERROR:....>)
From my point of view this should meet your expected behaviour.
Regards
Klaus Landwich
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2024-02-13
Hi Klaus Landwich,
there is still a question open for me. I evaluate SASUnit in the development of a frame work. Part of the framework is error handling. In the error handling the framework issues a %abort cancel command.
My testcase uses the framework, injects an error and then asserts the log for the error.
My hand coded assertLog seems never to be excecued. My assumption is, because of the %abort in the framework the test case is broken. Because of that the default log scan run.
Is that the case?
Thanks in advance.
Albert Meyn
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you are absolutely right.
It is common to have an %abort in some programs.
But it is obvious that this interfears with the test cases.
Can you isolate the functionality you want to test? So that it works without %abort?
Otherwise you could wrap the %abort statement into a macro, which evaluates some macro variables. Most of the time you don't want to issue an abort statement in the development or testing environment. If you already have some indication in which environment the programs are running, then use those.
If that is not the case you could check if there are global SASUnit macro variables. For instance with %symexist(G_SASUNIT_ROOT). So you have an indication when to skip the abort statement.
It is second best to change the code you want to test to work in the unit tests, but sometimes there is no other way.
Hope this is of any help.
Regards
Klaus Landwich
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear All,
I have a "negativ test" case, which must produce an error. So the excpected behaviour is to find in the Log an "ERROR:".
Is it possible to parameterize the Log Scan in a way, that finding "ERROR:" will cause a "passed" entry in the file "log4sasunit_asserts.log"?
Thank you very much.
Kind Regards
Albert Meyn
W&W Informatik GmbH
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.
This email may contain confidential and/or privileged information. If you are not the intended recipient (or have received this email in error) please notify the sender immediately and destroy this email. Any unauthorized copying, disclosure or distribution of the material in this email is strictly forbidden.
Dear All,
at the end of a test case the log is automatically scanned for "ERROR:" I do not see a possibility to parameterize this log scan.
For a "negative test" I inject an error. So the expectation is, that the error in the log shoud be reported as
OK~001~1~1~assertLog~0~0#0~0#0~assertLog: assert passed.
Actually it is reported as:
ERROR~001~1~1~assertLog~2~0#0~3#0~assertLog failed:
Do I have the possibilty to change this behaviour?
Thank you very much.
Albert Meyn
W&W Informatik GmbH
Hi Albert Meyn,
yes it is possible to parameterize the logscan.
By design SASUnit adds a log scan at the end of the scenario. This happens when no log scan was implemented by the user.
Your problem can be solved by an explicit call to the macro assertLog.
Here you can specify then number of expected errors and warnings in the log (parameter i_errors and i_warnings.
As an example:
To make sure that you allow the expected error only, you can add a call to assertLogMsg:
From my point of view this should meet your expected behaviour.
Regards
Klaus Landwich
Hi Klaus Landwich,
there is still a question open for me. I evaluate SASUnit in the development of a frame work. Part of the framework is error handling. In the error handling the framework issues a %abort cancel command.
My testcase uses the framework, injects an error and then asserts the log for the error.
My hand coded assertLog seems never to be excecued. My assumption is, because of the %abort in the framework the test case is broken. Because of that the default log scan run.
Is that the case?
Thanks in advance.
Albert Meyn
Hi Albert Meyn,
you are absolutely right.
It is common to have an %abort in some programs.
But it is obvious that this interfears with the test cases.
Can you isolate the functionality you want to test? So that it works without %abort?
Otherwise you could wrap the %abort statement into a macro, which evaluates some macro variables. Most of the time you don't want to issue an abort statement in the development or testing environment. If you already have some indication in which environment the programs are running, then use those.
If that is not the case you could check if there are global SASUnit macro variables. For instance with
%symexist(G_SASUNIT_ROOT)
. So you have an indication when to skip the abort statement.It is second best to change the code you want to test to work in the unit tests, but sometimes there is no other way.
Hope this is of any help.
Regards
Klaus Landwich