InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

Extend the use of some testing macros to examples

Open
#1,275 1 comment 0 reactions 0 assignees View on GitHub
status:Use_Milestone_Backlog type:Design
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

### Description

Derived from [this PR to fix a bug](https://github.com/InsightSoftwareConsortium/ITKExamples/pull/135/) it would may be useful to be able to use the `ITK_TRY_EXPECT_NO_EXCEPTION` macro also in the ITK Examples.

The macro is currently defined in [`itkTestingMacros.h`](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/TestKernel/include/itkTestingMacros.h), and is virtually never used in the ITK code base or Examples because may be including [`itkTestingMacros.h`] in such files is counter-intuitive indeed.

So may be it should be moved to elsewhere, since in reality, `try/catch` blocks are not really limited to tests and examples.

It would avoid writing boilerplate code, and making the exception messages consistent.

### Impact analysis

It would allow to avoid bugs such as the one mentioned, would make the code more consistent, have less boilerplate code, and no downsides to it can are foreseen.

### Expected behavior

Be able to call
```
ITK_TRY_EXPECT_NO_EXCEPTION( filter->Update() );
```

macros from the ITK code base or Examples including some header file other than `itkTestingMacros.h`, which seems counter-intuitive.

### Actual behavior

The `ITK_TRY_EXPECT_NO_EXCEPTION` macros is virtually never used in the ITK code base or the Examples.

### Versions

`master`

### Additional Information

One may wonder what to do with `TRY_EXPECT_EXCEPTION` then, since that is really intended for tests.

Naming may need to be taken care of. Almost all macros in [itkTestingMacros](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/TestKernel/include/itkTestingMacros.h) have the prefix `TEST`. And a few do not.

Related to #1273.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.