[ 
https://issues.apache.org/jira/browse/DRILL-6249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16468449#comment-16468449
 ] 

ASF GitHub Bot commented on DRILL-6249:
---------------------------------------

paul-rogers commented on a change in pull request #1251: DRILL-6249: Adding 
more unit testing documentation.
URL: https://github.com/apache/drill/pull/1251#discussion_r186936197
 
 

 ##########
 File path: docs/dev/MockingComponents.md
 ##########
 @@ -0,0 +1,96 @@
+# Mocking Components
+
+There are a few techniques for mocking classes in unit tests:
+
+* Use a mocking library
+* Provide a simple impementation of an interface
+* Build a real instance of class using the class's builders / constructors
+* 
+
+## Mocking Libraries
+
+Drill uses two mocking libraries in order to mock classes.
+
+* [Mockito](http://site.mockito.org)
+* [JMockit](http://jmockit.github.io/tutorial.html) (Deprecated)
+
+While some tests use [JMockit](http://jmockit.github.io/tutorial.html), its 
usage has been deprecated since it doesn't work well with
+eclipse. Specifically any test that uses JMockit will fail when run with 
eclipse. So if you
+need to use a mocking library use [Mockito](http://site.mockito.org).
+
+## Mocking Contexts
+
+There are several contexts used throughout Drill, for a complete description 
of each and how
+they are used please see 
[FragmentContextImpl](../../exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContextImpl.java).
+
+When doing tests you can use the following mock contexts:
+
+  * 
[MockFragmentContext](../../exec/java-exec/src/test/java/org/apache/drill/test/OperatorFixture.java)
 is a simple mock implementation of
+  the 
[FragmentContext](../../exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java).
+
+## Creating An Instance of 
[QueryId](../../protocol/src/main/java/org/apache/drill/exec/proto/beans/QueryId.java)
+
+```
+UserBitShared.QueryId queryId = UserBitShared.QueryId.newBuilder()
+  .setPart1(1L)
+  .setPart2(2L)
+  .build();
+```
+
+## Creating 
[FragmentHandle](../../protocol/src/main/java/org/apache/drill/exec/proto/beans/FragmentHandle.java)
+
+```
+ExecProtos.FragmentHandle fragmentHandle = 
ExecProtos.FragmentHandle.newBuilder()
+  .setQueryId(queryId)
+  .setMinorFragmentId(1)
+  .setMajorFragmentId(2)
+  .build();
+```
+
+## Creating A 
[DrillConfig](../../common/src/main/java/org/apache/drill/common/config/DrillConfig.java)
+
+There are a few ways to create a 
[DrillConfig](../../common/src/main/java/org/apache/drill/common/config/DrillConfig.java).
 See the class for all of them. The simplest way is to
+ create a default config.
+
+```
+DrillConfig config = DrillConfig.create();
 
 Review comment:
   See the `ConfigBuilder`. It is the guts behind the `ClusterFixture` and 
`OperatorFixture` for configs. It allows the fluent-style construction used in 
these two contexts.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add Markdown Docs for Unit Testing and Link to it in README.md
> --------------------------------------------------------------
>
>                 Key: DRILL-6249
>                 URL: https://issues.apache.org/jira/browse/DRILL-6249
>             Project: Apache Drill
>          Issue Type: Improvement
>            Reporter: Timothy Farkas
>            Assignee: Timothy Farkas
>            Priority: Major
>              Labels: ready-to-commit
>             Fix For: 1.14.0
>
>
> I am working on a presentation about how to use the unit testing utilities in 
> Drill. Instead of writing the doc and having it be lost in Google Drive 
> somewhere I am going to add a Markdown doc to the drill repo and link to it 
> in the README.md. This is appropriate since these docs will only be used by 
> developers, and the way we unit test will change as the code changes. So the 
> unit testing docs should be kept in the same repo as the code so it can be 
> updated and kept in sync with the rest of Drill.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to