Produce a diagnistic once per failed test method?
조회 수: 2 (최근 30일)
이전 댓글 표시
Is it possible to produce a diagnostic once per failed test method (as opposed to once per verify/assert, which is what TestCase.onFailure does)?
A common scenario in my test code is that I read some input data, process it and make several testCase.verify... on the processed data. If one or more verifications fail, I wish to produce a diagnostic message with the input data, but only once per test method to not pollute the log.
댓글 수: 1
Adam
2020년 1월 31일
Would this not just be a case of using regular Matlab conditional checks for all your intermediate cases and then using a single verify on an ANDed combination of these? Possibly with shortcuts in place if you want it to happen as soon as you hit a failure rather than running all your verifications.
채택된 답변
추가 답변 (1개)
Steven Lord
2020년 1월 31일
If you want to store your data, why not use a FileArtifact diagnostic? You could put it in a temporary folder created by a TemporaryFolderFixture (with 'PreservingOnFailure' set to true, so the folder is not deleted if a failure occurs) so you'll have access to it after the test finishes executing.
Or just skip the diagnostic and write your files to a TemporaryFolderFixture's folder, or a WorkingFolderFixture's folder, etc. If the test passes, that data is no longer needed and gets cleared when the fixture is destroyed. If it doesn't, and you've told the fixture to spare the folder on failure, the test should show you exactly where the data is located.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Function-Based Unit Tests에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!