Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

VcfToBqTask unit tests#19

Open
mjfeigles wants to merge 4 commits into
googleinterns:masterfrom
mjfeigles:task-testing
Open

VcfToBqTask unit tests#19
mjfeigles wants to merge 4 commits into
googleinterns:masterfrom
mjfeigles:task-testing

Conversation

@mjfeigles

Copy link
Copy Markdown
Contributor

Unit tests for VcfToBqTask.java:

  • tests VcfToBqTask constructor
  • tests run()
    • verifies that the 3 function calls inside run() are executed
  • tests setPipelineOptions()
    • verifies that setPipelineOptions() is callable
    • does not test static function FileSystems.setDefaultPipelineOptions()
  • does not test static main(), which runs a static function to create injector and get injector instance

@mjfeigles mjfeigles requested a review from tneymanov July 13, 2020 21:23
Comment thread .gitignore
gcp-variant-transforms-java.iml

#Ignore VSCode files
.vscode/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this added in previous PRs? Doesn't matter much, but maybe some commit mishap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this commit still affects this PR. Maybe we can take it out

bind(VcfParser.class).to(VcfParserImpl.class);
bind(Task.class).to(VcfToBqTask.class);
}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should had been created in Zhiqiang's PR right? Could you sync and update the PR?

VcfToBqTask vcfToBqTask;
VcfToBqTask spyVcfToBqTask;

@Mock

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can inline, just to save space stylistically:

@mock PipelineRunner mockedPipelineRunner.

Here and below.

ImmutableList<String> headerLines = headerLinesBuilder.build();
doReturn(headerLines).when(mockedHeaderReader).getHeaderLines();
doNothing().when(spyVcfToBqTask).setPipelineOptions(argCaptorPipelineOptions.capture());
doNothing().when(mockedVcfToBqContext).setHeaderLines(argCaptorImmutableList.capture());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we, specifically for this case, use headerLines instead of capturing? The problem with PipelineOptions was that the object was changed (type casted into PipelineOptions). Here I don't think we have the same issue.

setUpRunBehaviors();
spyVcfToBqTask.run();

verify(mockedVcfToBqContext).setHeaderLines(argCaptorImmutableList.capture());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part we can just check by checking that it was called with headerLines (since they have not been modified).


@Test
public void testVcfTask_whenSetPipelineOptions_thenVerify() throws Exception {
doNothing().when(spyVcfToBqTask).setPipelineOptions(argCaptorPipelineOptions.capture());;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is kinda pointless, tbh. We just call the function here and verify that function has been called. I say we remove it.

}

@Test
public void testVcfTask_whenRun_thenVerifySetPipelineOptions() throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can combine all three tests into one.

setUpRunBehaviors();
spyVcfToBqTask.run();

verify(spyVcfToBqTask).setPipelineOptions(mockedVcfToBqOptions);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this passes... wasn't the whole purpose of using arg captor was that the value was modified on runtime and thus, we couldn't have expected it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants