Goddard-Fortran-Ecosystem / pFUnit

Parallel Fortran Unit Testing Framework
Other
173 stars 45 forks source link

How do esmf test extensions work or more examples #285

Open kurtsansom opened 3 years ago

kurtsansom commented 3 years ago

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

tclune commented 3 years ago

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".

kurtsansom commented 3 years ago

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?

tclune commented 3 years ago

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.