-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Activity mock #6301
base: master
Are you sure you want to change the base?
Activity mock #6301
Conversation
ActivityIT first one separate annotations to keep track and easier create screenshots Signed-off-by: tobiasKaminsky <[email protected]>
Issues
======
+ Solved 2
- Added 2
Complexity increasing per file
==============================
- src/main/java/com/nextcloud/client/di/ActivitiesModule.java 1
See the complete overview on Codacy |
((retryCount++)) | ||
done | ||
|
||
sed -i s'#<bool name="is_beta">true</bool>#<bool name="is_beta">false</bool>#'g src/main/res/values/setup.xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
scripts/wait_for_emulator.sh | ||
|
||
sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/14494.apk |
stable-Unit test failed, but no output was generated. Maybe a preliminary stage failed. |
master-Unit test failed, but no output was generated. Maybe a preliminary stage failed. |
Codacy397Lint
SpotBugs (new)
SpotBugs (master)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand it correctly, we have a specialized app to conduct screenshot tests, right?
And we want to swap network I/O layer to eliminate reliance on live server?
Swapping big compinents for tests is the right approach to do it. Ideally, we'd like to swap 1 component to achieve it, but with network ops spread between independent *Operation
classes, doing it at HTTP client level seems to be a reasonable choice.
However, this will be really tedious and fragile to mock, as mock responses would have to track server changes. Of course this could be worked out as well with suitable refactoring, but the question about cost to benefit ratio must be answered first.
import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.TAG; | ||
|
||
public class LocalActivitiesRepository implements ActivitiesRepository { | ||
String json = "{\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kotlin allows to use """
to denote raw strings that do not need any escaping. It's really handy for stuff like that and regexps.
@@ -119,12 +119,16 @@ public ActivityListAdapter( | |||
this.storageManager = storageManager; | |||
this.capability = capability; | |||
this.clientFactory = clientFactory; | |||
try { | |||
this.client = clientFactory.createNextcloudClient(currentAccountProvider.getUser()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that cause NPE
somewhere down the line?
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface ScreenshotWithServerTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it called with server?
@@ -240,6 +238,14 @@ protected void attachBaseContext(Context base) { | |||
} | |||
} | |||
|
|||
@VisibleForTesting | |||
public void setupDagger() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make it protected
.
Yes.
I have two approaches…
My intention was to have a reproducable state, and ideally no external components (e.g. docker) needed (this is true for option 1/2). |
True.
So if there are api changes on server they would first be captured by library. But as you said, I am really uncertain about time effort with this interceptor approach… |
Testing
Writing tests is very important. Please try to write some tests for your PR.
If you need help, please do not hesitate to ask in this PR for help.
unit tests
instrumented tests
UI tests