# Wrapping predicates

**URL:** <https://swi-prolog.discourse.group/t/wrapping-predicates/668>\
**Category:** Request For Comments\
**Created:** [May 19, 2019, 2:27pm UTC](https://swi-prolog.discourse.group/t/wrapping-predicates/668 "2019-05-19T14:27:12Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [May 19, 2019, 9:37pm UTC](https://swi-prolog.discourse.group/t/wrapping-predicates/668/21 "2019-05-19T21:37:08Z")

</div>

> [@pmoura](#):
>
> I never found a way to implement _around_ methods using _before_ and _after_ methods. I don’t say that it is not possible but I doubt it.

In [JUnit 5](https://junit.org/junit5/docs/current/user-guide/) which is one of the standard [Unit Tes](https://en.wikipedia.org/wiki/Unit_testing)t platforms for Java there is a resource allocation [example](https://junit.org/junit4/faq.html#organize_3) that uses @Before on line 23 to create a collection and then uses @After on line 28 to clear the collection. Because all of the wrapper methods are implemented in one class the methods can pass state via an instance value without passing via the wrapped method arguments.

---

_[View the full topic](https://swi-prolog.discourse.group/t/wrapping-predicates/668)._
