You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@opennlp.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/10/08 22:14:00 UTC
[jira] [Commented] (OPENNLP-1338) Refactor DummyNameFinder to
improve test logic
[ https://issues.apache.org/jira/browse/OPENNLP-1338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17426401#comment-17426401 ]
ASF GitHub Bot commented on OPENNLP-1338:
-----------------------------------------
jzonthemtn merged pull request #396:
URL: https://github.com/apache/opennlp/pull/396
--
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.
To unsubscribe, e-mail: dev-unsubscribe@opennlp.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
> Refactor DummyNameFinder to improve test logic
> ----------------------------------------------
>
> Key: OPENNLP-1338
> URL: https://issues.apache.org/jira/browse/OPENNLP-1338
> Project: OpenNLP
> Issue Type: Improvement
> Reporter: Xiao Wang
> Priority: Minor
>
> h3. Description
> I noticed that there is a test class [DummyNameFinder|https://github.com/apache/opennlp/blob/7286f9c804b65a4a1d771d3c984ea76516fc8141/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderEvaluatorTest.java#L95] implements production interface [TokenNameFinder|https://github.com/apache/opennlp/blob/7286f9c804b65a4a1d771d3c984ea76516fc8141/opennlp-tools/src/main/java/opennlp/tools/namefind/TokenNameFinder.java#L25] to assist testing [Evaluator.evaluateSample(NameSample)|https://github.com/apache/opennlp/blob/7286f9c804b65a4a1d771d3c984ea76516fc8141/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java#L78]. This might not be the best priactice in unit testing and can be improved by leveraging mocking frameworks.
> h3. Current Implementation
> * {{DummyNameFinder}} implements {{TokenNameFinder}} and overrides methods to return fixed object for {{find()}}.
> * In test case, the child test class is used to assit testing by passing as a parameter to contructor of {{TokenNameFinderEvaluator}}.
> h3. Proposed Implementation
> * Replace {{DummyNameFinder}} with a mocking object created by Mockito.
> * Use method stub to control the behavior of {{find()}}.
> * Create a method to return the mocking object for reusing.
> h3. Motivation
> * Decouple test class {{DummyNameFinder}} from production interface {{TokenNameFinder}}.
> * Remove the redundant test child class {{PrintingVisitor}}
> * Remove the redundant overridden methods {{clearAdaptiveData()}}
> * Make testing logic more explict.
> h3. More Thought
> * We can further improve the testing logic by creating mock object inside of the test case and only stub {{find(String[])}} method.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)