You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Kihwal Lee (JIRA)" <ji...@apache.org> on 2011/08/11 20:30:27 UTC

[jira] [Created] (HADOOP-7537) Add PowerMock for the development of better tests

Add PowerMock for the development of better tests
-------------------------------------------------

                 Key: HADOOP-7537
                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
             Project: Hadoop Common
          Issue Type: Improvement
          Components: build
    Affects Versions: 0.23.0
            Reporter: Kihwal Lee
            Assignee: Kihwal Lee
            Priority: Minor
             Fix For: 0.23.0


We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-lever features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kihwal Lee updated HADOOP-7537:
-------------------------------

    Description: We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this.   (was: We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-lever features without this. )

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kihwal Lee updated HADOOP-7537:
-------------------------------

    Status: Patch Available  (was: Open)

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-lever features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Hadoop QA (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13086372#comment-13086372 ] 

Hadoop QA commented on HADOOP-7537:
-----------------------------------

-1 overall.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12490165/powermock.patch
  against trunk revision .

    +1 @author.  The patch does not contain any @author tags.

    -1 tests included.  The patch doesn't appear to include any new or modified tests.
                        Please justify why no new tests are needed for this patch.
                        Also please list what manual steps were performed to verify this patch.

    +1 javadoc.  The javadoc tool did not generate any warning messages.

    +1 javac.  The applied patch does not increase the total number of javac compiler warnings.

    +1 findbugs.  The patch does not introduce any new Findbugs (version 1.3.9) warnings.

    +1 release audit.  The applied patch does not increase the total number of release audit warnings.

    +1 core tests.  The patch passed core unit tests.

    +1 contrib tests.  The patch passed contrib unit tests.

    +1 system test framework.  The patch passed system test framework compile.

Test results: https://builds.apache.org/job/PreCommit-HADOOP-Build/45//testReport/
Findbugs warnings: https://builds.apache.org/job/PreCommit-HADOOP-Build/45//artifact/trunk/target/newPatchFindbugsWarningshadoop-common.html
Findbugs warnings: https://builds.apache.org/job/PreCommit-HADOOP-Build/45//artifact/trunk/target/newPatchFindbugsWarningshadoop-annotations.html
Console output: https://builds.apache.org/job/PreCommit-HADOOP-Build/45//console

This message is automatically generated.

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-lever features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kihwal Lee resolved HADOOP-7537.
--------------------------------

    Resolution: Won't Fix

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Work started] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on HADOOP-7537 started by Kihwal Lee.

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Scott Carey (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13088912#comment-13088912 ] 

Scott Carey commented on HADOOP-7537:
-------------------------------------

I have had mostly bad experiences with PowerMock. As Todd says, it is usually indicative of something that needs to be refactored or fixed; or is simply mis-used.

Tests that use too much PowerMock are extremely brittle, often failing in test code B after after changes in seemingly unrelated code A in ways that require deep knowledge of B.  It does some funky stuff in classloader land that results in painful to debug issues.  For example, I have seen static code initialized twice, leading to a test that hangs forever.

We have started to use phrases like "friends don't let friends abuse PowerMock".  Fixing a broken PowerMock test takes much longer than fixing an ordinary test.

It is a useful tool to have around, but needs to be used judiciously.   Every time it is used "because I must mock XYZ" ask, "why does XYZ need to be mocked? does it need changes to design to be testable?"

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13088694#comment-13088694 ] 

Kihwal Lee commented on HADOOP-7537:
------------------------------------

@eric I think no dependency in hadoop-project has its scope defined. The pom.xml in each subproject contains scope. 

@todd I am using it for the RPC server address change detection test. It requires mocking the constructor of InetSocketAddress.

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13089695#comment-13089695 ] 

Todd Lipcon commented on HADOOP-7537:
-------------------------------------

I think EnvironmentEdge is a better approach, and would prefer to see this used as sparingly as possible. But I don't feel so strongly as to -1 it. I may -1 other patches in the future that use powermock, though, when a better design would be possible. Of course, I'm also not going to +1 it :)

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13086376#comment-13086376 ] 

Kihwal Lee commented on HADOOP-7537:
------------------------------------

No test needed as the patch only adds dependencies.

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-lever features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13088942#comment-13088942 ] 

Kihwal Lee commented on HADOOP-7537:
------------------------------------

I understand the concerns. If we decide to add PowerMock, a strong warning should be put at http://wiki.apache.org/hadoop/HowToDevelopUnitTests. 

The test I am writing is for detecting state changes external to JVM. E.g. IP address changes.

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kihwal Lee updated HADOOP-7537:
-------------------------------

    Attachment: powermock.patch

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-lever features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13089629#comment-13089629 ] 

Todd Lipcon commented on HADOOP-7537:
-------------------------------------

How so? If you have access to arbitrarily put new untrusted classes on the classpath of a server, then we've already lost...

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13098092#comment-13098092 ] 

Kihwal Lee commented on HADOOP-7537:
------------------------------------

Thank you all for suggestions. I will close this bug as "won't fix' and look for other ways.

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Luke Lu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13089714#comment-13089714 ] 

Luke Lu commented on HADOOP-7537:
---------------------------------

bq. It requires mocking the constructor of InetSocketAddress.

Instead of introducing PowerMock, which can lead to test failures in unrelated tests. How about just introduce an InetSocketAddress factory? In this particular case, what you really want to control is the DNS resolution. How about just introduce a NodeNameResolver interface and a DefaultNodeNameResolver singleton to manage the resolver (so you can use a test resolver to supply mocks)?

If we find that we need to do too many such exercises, we'd better off using a complete (but still lightweight) DI solution like Guice (which can be introduced into our code incrementally), which is already a maven dependency in our code base :)

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Eric Yang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13088047#comment-13088047 ] 

Eric Yang commented on HADOOP-7537:
-----------------------------------

Dependency for Hadoop project doesn't specify the scope.  Should this be for testing only for Hadoop-project?

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Jeffrey Naisbitt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13083561#comment-13083561 ] 

Jeffrey Naisbitt commented on HADOOP-7537:
------------------------------------------

Could we add this to http://wiki.apache.org/hadoop/HowToDevelopUnitTests (where it briefly describes using mockito, we could mention powermock)

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-lever features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Work stopped] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on HADOOP-7537 stopped by Kihwal Lee.

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kihwal Lee updated HADOOP-7537:
-------------------------------

    Status: Open  (was: Patch Available)

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13089691#comment-13089691 ] 

Kihwal Lee commented on HADOOP-7537:
------------------------------------

We should still discuss alternative ways of design/testing, but I am looking for a brave soul who can put the last nail on the coffin. If someone -1 the idea/patch, I will close it as "won't fix". Scott? Todd? 

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13089014#comment-13089014 ] 

Todd Lipcon commented on HADOOP-7537:
-------------------------------------

The way we've mocked things like this in HBase is to use a class called "EnvironmentEdge". The default implementation simply forwards calls to the normal JVM implementations (eg envEdge.currentTimeMillis() calls System.currentTimeMillis()). It's then easy to mock this by replacing an instance within a particular class with a mock. Could we do the same thing with the construction of InetSocketAddress?

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Kihwal Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13089467#comment-13089467 ] 

Kihwal Lee commented on HADOOP-7537:
------------------------------------

I took a look at EnvironmentEdge in HBase. 
Maybe it's an ignorant question, but can this be a security hole?

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HADOOP-7537) Add PowerMock for the development of better tests

Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13088088#comment-13088088 ] 

Todd Lipcon commented on HADOOP-7537:
-------------------------------------

I've also often wanted PowerMock. My only question is whether we should treat its usage as a red flag -- I think often it's indicatve of a design issue in the code. Where did you run into something that was untestable without it?

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can mock constructors and static methods. I find that it is extremely difficult, if not impossible, to properly test some of the low-level features without this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira