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

name.abuchen.portfolio.junit doesn't have dependency on Mockito, and can't add one #4480

Open
pfalcon opened this issue Jan 18, 2025 · 0 comments

Comments

@pfalcon
Copy link
Contributor

pfalcon commented Jan 18, 2025

@buchen :

I treat name.abuchen.portfolio.junit as a package for helpers related to testing. (In that regard, I'm not sure why BookmarkTest.java , a lone test, lives there? Is that kinda to be able to build and run name.abuchen.portfolio.junit in "executable" form, or is it just misplaced and should be moved to name.abuchen.portfolio.tests?)

I'd like to add more convenience methods, in particular, to easier mock LocalDate.now(). Well, I can't, because name.abuchen.portfolio.junit doesn't have dependency on Mockito, and due to weirdnes high-level nature of Maven, I can't see how to add it. Nowhere (in *.junit vs *.tests) does Mockito mentioned explicitly, the only test-related difference I could easily see between the 2 packages is:

--- .classpath	2025-01-11 16:48:04.126757219 +0700
+++ .classpath	2025-01-11 16:22:51.173727603 +0700
@@ -6,6 +6,10 @@
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="src">
+		<attributes>
+			<attribute name="test" value="true"/>
+		</attributes>
+	</classpathentry>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>

, but adding that <attribute name="test" value="true"/> to .junit doesn't help with the issue.

So, could suggest how to add that dependency (w/o Eclipse IDE), or could you add it yourself, or would it otherwise be ok to add helper classes to .tests? (But then it would be all over the place, with tests and helpers randomly spread between 2 packages).

public class TestHelper
{
    private TestHelper()
    {}

    public static MockedStatic<LocalDate> mockLocalDateNow(String isoDate)
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

1 participant