pFUnit icon indicating copy to clipboard operation
pFUnit copied to clipboard

How do esmf test extensions work or more examples

Open kurtsansom opened this issue 3 years ago • 3 comments

Hi I am looking for an example that use the @begin idiom, but can't seem to find an example.

kurtsansom avatar Apr 13 '21 15:04 kurtsansom

I just scanned most/all of my projects that use pFUnit, and did not find any examples either. I think the original intent was to allow for two Fortran test modules to be in the same file, and quite possibly the feature was never even completed. My style is to only have one module per file, so I've not missed the feature. And my memory is atrocious, so I may even be wrong about the intent.

You could try to put two small test modules into a single file and use @begin before each. But I'm fairly certain it won't work. But in that case the documentation could simply be "unsupported" or "incomplete".

tclune avatar Apr 13 '21 16:04 tclune

I was looking at JUnit5, and read about @BeforeEach and @BeforeAll, I think pFUnit @before is analogous to @BeforeEach. Is there a decorator analogous to @BeforeAll in pFUnit?

kurtsansom avatar Apr 13 '21 16:04 kurtsansom

No there is no analog for @BeforeAll in pFUnit. I don't think it would be too difficult to introduce the feature, but it's sort of hard to come up with motivating use cases. I've not gone back to read the JUnit documentation, but I would think the cases that motivate this are where you want to have a shared resource that persists across the tests. That might make sense if the shared resource is expensive to initialize or one wanted to have a dependency between the tests. The latter I try to avoid and the former seems rare in practice.

I would love to be able to use something like @BeforeAll to initialize/finalize MPI for a group of tests, but alas, most MPI implementations are not re-entrant, so I'm left doing that outside all of the tests. I suppose if I worked with databases, that is another likely area where the feature would be potentially useful.

tclune avatar Apr 13 '21 19:04 tclune