Giter Club home page Giter Club logo

Comments (4)

vidstige avatar vidstige commented on August 16, 2024

But only public classes/functions are ever tested by design. Which class would you like to test? Please explain a bit more about this "problem".

from jadb.

SKART1 avatar SKART1 commented on August 16, 2024

For example - see this cross-repository comparison of #38.

Shortly - I want to implement getprop command of android device.

To make this feature testable I separated this functionality in 2 parts:

  • executing shell command
  • parsing inputstream as a result.

This allows to test most complicated part without overriding executeShell method
Not to put garbage in module interface only actual getprop method is public and parseProp is not.
To actually call this method I need package level access which can be achieved only if test have the same package name as testable class

P.S. Unit tests philosophy (as I understand - I may be wrong) is to test as little parts of the system as it is possible to reduce interference of different bugs from different modules. So if part of the system is implemented in package local class - it is no problem to test it alone even it is not visible for clients

from jadb.

vidstige avatar vidstige commented on August 16, 2024

I see, I think it would be a much cleaner solution to just mock the public interface. That way you test behavior rather than implementation. The latter is less likely to change, and if it does change you want to change the test. Pros:

  • Calls the function exactly as a user of the library would.
  • You can also assert what the actual command was, e.g. getprop
  • No need to expose internal (default visible) methods.
  • No needs to mix integration and unit tests.

Disadvantage:

  • You will need to extend the FakeAdbServer to also handle executeShell output. I can probably help out with this.

from jadb.

vidstige avatar vidstige commented on August 16, 2024

Plan B - Just make the getprop() function public

from jadb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.