New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit test for PackageManager
#72
Comments
Hi ! I'm new , I'm trying to understand how work the big world of GitHub. |
Yes, please, that would be very much appreciated. This is a matter of adding a new unit test fixture class with a few unit tests. Let me ask you some questions about your background. Have you worked with unit tests before? How familiar are you with Java? |
I'm studying Java at university, but at the moment, we haven't talk about the unit tests classes. So I've never worked with these type of classes. |
Alright. It's going to be fine. You'll learn a lot. What editor do you use? I recommend IntelliJ.
Let me know when you came thus far, or if you run into any snags. 😊 |
I've done it ! So the tests classes are classes where I try my main |
Great! :-) And the tests are green? So Real use scenarioApplication (in another repo) -> jadb -> Android device Unit testUnit test -> jadb -> Mocked device This has the benefit of not having to have an Android device connected when running the test, I can run then automatically whenever a code change is committed. See more here. Furthermore, the unit tests acts as examples on how to use the library. The next step is to create a new unit test. Easiest will be to just add a new function to the MockedTestCases.java file. You can start by adding a new function and make sure you can run it from within IntelliJ, then just to try it, make it fail by raising an exception in the function body. Next step is to create an instance of the PackageManager class we want to test, and calling a function on it, e.g. The way this works is that the package manager just invokes a program on the Android device called Does this all makes sense? Let me know if you have any questions regarding unit tests, or what to do next or if you run into and snags. |
Not all the tests are green, 15 test are ignored yellow color. |
Ok, that might be the integration tests... That's fine. You just write the code for a new function and re-run the tests. You should see the test name appear Try something like this
|
Yes, I've written in this mode, but I don't understand what to put in the method block. I leave it empty? |
Well, it's a process so empty body is a good start to get you going. Before this issue is done we want to test the PackageManager class. So we need to create an instance if this class, and call a method. And then assert something. |
Maybe you should try a tutorial to learn about unit testing first? |
Step by step, I understand ! :-) |
Great! 😊 And do you feel you have a way forward? |
I'm trying! :-) |
Any news? :) |
@vidstige : Could that be issue marked as resolved ? |
right, thanks! |
Looking at the code coverage over at codecov.io, I see I've missed to add unit tests for the
PackageManager
class. See more here: https://codecov.io/gh/vidstige/jadb/src/39dc7ee90f31bd97bba523ebb800ff2cf1f6621c/src/se/vidstige/jadb/managers/PackageManager.javaThis should be easy to add, glancing at the already existing unit test.s
The text was updated successfully, but these errors were encountered: