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

Tests in module arquillian-warp-api are never run #229

Open
rhusar opened this issue Oct 1, 2024 · 6 comments
Open

Tests in module arquillian-warp-api are never run #229

rhusar opened this issue Oct 1, 2024 · 6 comments
Labels

Comments

@rhusar
Copy link
Collaborator

rhusar commented Oct 1, 2024

It looks like these are only meant to be 'compiled' but never run but the execution was never disabled in maven.

These tests would require the impl to be available, so they need to be reworked to Mocks.

2024-09-30T12:06:54.2882433Z [INFO] --- maven-surefire-plugin:3.2.5:test (default-test) @ arquillian-warp-api ---
2024-09-30T12:06:54.2983145Z [INFO] Using auto detected provider org.apache.maven.surefire.junit4.JUnit4Provider
2024-09-30T12:06:54.4278328Z [INFO] 
2024-09-30T12:06:54.4286272Z [INFO] -------------------------------------------------------
2024-09-30T12:06:54.4287067Z [INFO]  T E S T S
2024-09-30T12:06:54.4287771Z [INFO] -------------------------------------------------------
2024-09-30T12:06:54.7302452Z [INFO] 
2024-09-30T12:06:54.7303037Z [INFO] Results:
2024-09-30T12:06:54.7304547Z [INFO] 
2024-09-30T12:06:54.7327997Z [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

FYI @WolfgangHG - this one is quite funny :-)

@WolfgangHG
Copy link
Contributor

@rhusar Do you mean those two?
grafik

Do you have any idea what to do about them? I browsed the history, and the initial commit from 2012 still contained @Test annotations and some mocks for variables, but this was removed afterwards, further methods were added, but none are invoked.

So I have no idea what this piece of code should actually do and why parts of the class were removed ;-).

@rhusar
Copy link
Collaborator Author

rhusar commented Nov 18, 2024

Yes, those in API module. I think these were meant to be just mocks, just to avoid accidentally breaking the API contract, but for some reason that was dropped and never restored. But those are compiled, so basically, little to lose here anyway,...

@WolfgangHG
Copy link
Contributor

Your explanation sounds reasonable ;-). So, what to do about them and this issue?

@rhusar
Copy link
Collaborator Author

rhusar commented Nov 18, 2024

I suppose just make them @ Test -s again and use mocking.

@WolfgangHG
Copy link
Contributor

OK, I will take a look the next few days. But I will have much more questions on the way ;-)

@WolfgangHG
Copy link
Contributor

@rhusar Help ;-)... This issue turns out to become a Mockito tutorial...

I started with the first method in TestObserverBuilderAPI:

public void testFilterBuilderUriNot() {      
    Warp
        .initiate(activity)
        .observe(request().uri().not().endsWith(".jsf"))
        .inspect(inspection);
}

..and tried to split it to pieces and mock it:

public void testFilterBuilderUriNot() {
  WarpExecutionBuilder mockBuilder = Mockito.mock(WarpExecutionBuilder.class);
  MockedStatic<Warp> mockWarp = Mockito.mockStatic(Warp.class);
  mockWarp.when(() -> Warp.initiate(activity)).thenReturn(mockBuilder);
  
  WarpExecutionBuilder realBuilder = Warp.initiate(activity) ;
  
  //call "observe":
  SingleInspectionSpecifier mockInspectionSpecifier = Mockito.mock(SingleInspectionSpecifier.class);
  //this line fails - "HttpFilters.request()" returns null.
  Mockito.when(realBuilder.observe(request().uri().not().endsWith(".jsf"))).thenReturn(mockInspectionSpecifier);
  
  SingleInspectionSpecifier realInspectionSpecifier = realBuilder.observe(request().uri().not().endsWith(".jsf"));

Should I mock "HttpFilters.request", too (and all the chain down)?

  MockedStatic<HttpFilters> mockFilters = Mockito.mockStatic(HttpFilters.class);
  //what should "request()" return? A mock to `HttpFilterBuilder`?

@rhusar rhusar added the bug label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants