Github user mmiklavc commented on the issue:

    https://github.com/apache/metron/pull/657
  
    One problem I see with this test is that it sets up the mock in a 
BeforeClass annotated init. That's generally frowned upon for mock tests that 
use verify() because expectations for the number of invocations is part of the 
api. A better alternative is to pull that mock out into an @Before. I rather 
like the idiom I've taken here best:
    
    ```
    public class PcapCliTest {
    
      @Mock
      private PcapJob jobRunner;
      @Mock
      private ResultsWriter resultsWriter;
      @Mock
      private Clock clock;
    
      @Before
      public void setup() {
        MockitoAnnotations.initMocks(this);
      }
    ```
    
    It keeps the setup lean and requires less boilerplate code (well, when you 
have multiple mocks, at least). Also, this approach will re-instantiate a new 
mock for every test, which I think is what we want in this case. It keeps the 
intent and expecations clear, to wit 1 invocation, not 1..n.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to