Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad filename for tests inherited from abstract class #419

Open
lmartelli opened this issue Sep 27, 2023 · 2 comments
Open

Bad filename for tests inherited from abstract class #419

lmartelli opened this issue Sep 27, 2023 · 2 comments

Comments

@lmartelli
Copy link

If a test class inherits test methods from a base class, the filenames for received/approved documents use the name of the base class.

For instance :

class MyTest {
	class BaseTest {
		@Test
		void sharedTest() {
			Approvals.verify("result");
		}
	}

	@Nested
	class NestedTest extends BaseTest {
	}
}

will generate MyTest.BaseTest.sharedTest.received.txt. It would be better to have MyTest.NestedTest.sharedTest.received.txt to avoid conflicts if when you have multiple tests classes that inherit from BaseTest.

@isidore
Copy link
Member

isidore commented Oct 12, 2023

I'm not sure I understand the purpose of have a BaseTest with unit tests that is extended.
Helping me understand this would probably yield a better solution.

However, as way of explanation, the Reflection API is detecting the class where the method is declared.

Probably it would be best to pair on this problem. Please reach out with an email and we will setup a zoom call.

@lmartelli
Copy link
Author

I'm not sure I understand the purpose of have a BaseTest with unit tests that is extended. Helping me understand this would probably yield a better solution.

I was testing email templates in several languages. The tests checked that the produced HTML contains correct data or links, whatever the language. My 1st approach was to create an abstract test class with all the tests, and one concrete non abstract test class per language. In the end, I introduced an enum for the supported languages and used @ParameterizedTest, which is a better approach I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants