-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix: Instrumented tests are executed in Drone CI again #16612
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
base: master
Are you sure you want to change the base?
Changes from all commits
29e3642
c51ee10
848cdd5
f0ee559
c468198
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ import com.owncloud.android.utils.DisplayUtils | |
| import io.mockk.MockKAnnotations | ||
| import io.mockk.every | ||
| import io.mockk.mockkStatic | ||
| import io.mockk.unmockkStatic | ||
| import org.junit.After | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Assert.assertNotNull | ||
| import org.junit.Assert.assertTrue | ||
|
|
@@ -47,10 +49,15 @@ class UploadDateTests { | |
| fun setup() { | ||
| context = InstrumentationRegistry.getInstrumentation().context | ||
| MockKAnnotations.init(this, relaxed = true) | ||
| mockkStatic(System::class) | ||
| mockkStatic(System::currentTimeMillis) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alperozturk96 see the commit message for more details: You should also see this test crash on your local machine. The test itself is green, but the whole test run is failed:
And the same now happens on the Drone job, now that it correctly picks up all expected tests. In the best case, the UploadDateTests should be a unit test, instead of an instrumented test. There, I expect the mocking of currentTimeMillis() to not interfere with outside processes. But in the git history I saw that you initially even had that test as unit test and then moved it over. As it is not explained in the commits, I don't know why. |
||
| every { System.currentTimeMillis() } returns JANUARY_27_2026 | ||
| } | ||
|
|
||
| @After | ||
| fun tearDown() { | ||
| unmockkStatic(System::currentTimeMillis) | ||
| } | ||
|
|
||
| @Test | ||
| fun uploadEntityConvertsToOCUploadAndBackCorrectly() { | ||
| val entity = UploadEntity( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ if [ -z $USER ] || [ -z $PASS ]; then | |
| fi | ||
| if [ $TYPE = "IT" ]; then | ||
| FOLDER=app/build/reports/androidTests/connected/flavors/gplay | ||
| FOLDER=app/build/reports/androidTests/connected/debug/flavors/gplay | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tobiasKaminsky these adjustments are needed so the report files are actually found. But reporting still is broken, which you can see e.g. in the log of https://drone.nextcloud.com/nextcloud/android/28585/1/3: It does upload the report to https://www.kaminsky.me/nc-dev/android-integrationTests/28585-IT-stable-10-44 but it fails to create the expected Github comment notifying the developer of this. |
||
| elif [ $TYPE = "Unit" ]; then | ||
| FOLDER=app/build/reports/tests/testGplayDebugUnitTest | ||
| else | ||
|
|
@@ -68,10 +68,10 @@ else | |
| -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \ | ||
| -d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }" | ||
| if [ -e app/build/reports/androidTests/connected/flavors/gplay ] ; then | ||
| if [ -e app/build/reports/androidTests/connected/debug/flavors/gplay ] ; then | ||
| TYPE="IT" | ||
| BRANCH_TYPE=$BRANCH-$TYPE | ||
| upload "app/build/reports/androidTests/connected/flavors/gplay" | ||
| upload "app/build/reports/androidTests/connected/debug/flavors/gplay" | ||
| fi | ||
| if [ -e app/build/reports/tests/testGplayDebugUnitTest ] ; then | ||
|
|
||

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.
@tobiasKaminsky with this, Drone now actually runs the instrumented tests again. See https://drone.nextcloud.com/nextcloud/android/28585/1/3 as a proof of failure, i.e. broken tests on master which were never detected.
I'll go ahead addressing the test failures. But there is several other things I noticed:
***withnextcloud, then it works. Is this redaction of secrets at play - if so, I surely hope, no secret token has simply "nextcloud" as value?