Tibor17 edited a comment on issue #285:
URL: https://github.com/apache/maven-surefire/pull/285#issuecomment-616765843
Hi @akomakom ,
> can you clarify what you're looking for here? Which method exists/doesn't?
I meant the method `getToolchains`. It was only some way on how the test
would know what version of Maven is executed. One test is suitable for low
version and the second for 3.3.0+. If you find easier way, that's even better
then.
> I tried to go down path number 1, but I'm finding that when I run tests,
the method never exists...
You will never be able to run the test for a new method in IntelliJ IDEA. It
would be possible only in the Maven build. So you have to create a new test
class and register the class in `JUnit4SuiteTest`. Then run the build `mvn
clean install` with **certain Maven version**.
> I should probably add that I've never worked with mockito so I'm guessing
my way through line by line.
In the beginning everything is difficult but you will play with
PowerMock.This test will help you `AbstractSurefireMojoJava7PlusTest`. There
are the same principles (mocking and verifying static method) you need to use
for `ReflectionUtils`. Mock the class `ReflectionUtils` and its static method.
You need to add `ReflectionUtils` to `@PrepareForTest( {
AbstractSurefireMojo.class, ResolvePathsRequest.class } )`, then `mockStatic(
ReflectionUtils.class );` and then use the paradightm:
`when( ReflectionUtils.someStaticMethod( ... ) ).thenReturn( ... )`.
Then call the method you wrote.
And then verify that the algorithm went through IF-ELSE, ..., and verify
expected number of calls with values, example:
`verifyStatic( ResolvePathsRequest.class, times( 1 ) );`
and verify values, example:
`ArgumentCaptor<Exception> argument2 = ArgumentCaptor.forClass(
Exception.class );`
`verify( logger, times( 1 ) ).warn( argument1.capture(), argument2.capture()
);`
Finally you will see that it was simple.
Feel free to start. Let's add the commit from my branch and create the test
class and register the class in suite. Then we will create empty test methods.
I will guide you.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]