mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Use Travis build number to avoid parallel tests interfere each other
This commit is contained in:
parent
c1564e8c38
commit
0149ee813d
@ -46,7 +46,7 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActiv
|
|||||||
|
|
||||||
private static final String LOG_TAG = CreateFolderTest.class.getCanonicalName();
|
private static final String LOG_TAG = CreateFolderTest.class.getCanonicalName();
|
||||||
|
|
||||||
private static final String FOLDER_PATH_BASE = "/testCreateFolder";
|
private static final String FOLDER_PATH_BASE = "/testCreateFolder" + Utils.getBuildNumber();
|
||||||
|
|
||||||
private TestActivity mActivity;
|
private TestActivity mActivity;
|
||||||
private String mCurrentDate;
|
private String mCurrentDate;
|
||||||
|
@ -37,7 +37,7 @@ public class CreateShareTest extends ActivityInstrumentationTestCase2<TestActivi
|
|||||||
private static final String LOG_TAG = CreateShareTest.class.getCanonicalName();
|
private static final String LOG_TAG = CreateShareTest.class.getCanonicalName();
|
||||||
|
|
||||||
/* File to share.*/
|
/* File to share.*/
|
||||||
private static final String FILE_TO_SHARE = "/fileToShare.txt";
|
private static final String FILE_TO_SHARE = "/fileToShare" + Utils.getBuildNumber() + ".txt";
|
||||||
|
|
||||||
private TestActivity mActivity;
|
private TestActivity mActivity;
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ public class DeleteFileTest extends ActivityInstrumentationTestCase2<TestActivit
|
|||||||
private static final String LOG_TAG = DeleteFileTest.class.getCanonicalName();
|
private static final String LOG_TAG = DeleteFileTest.class.getCanonicalName();
|
||||||
|
|
||||||
/* Folder data to delete. */
|
/* Folder data to delete. */
|
||||||
private static final String FOLDER_PATH = "/folderToDelete";
|
private static final String FOLDER_PATH = "/folderToDelete" + Utils.getBuildNumber();
|
||||||
|
|
||||||
/* File to delete. */
|
/* File to delete. */
|
||||||
private static final String FILE_PATH = "/fileToDelete.txt";
|
private static final String FILE_PATH = "/fileToDelete" + Utils.getBuildNumber() + ".txt";
|
||||||
|
|
||||||
private static boolean mGlobalSetupDone = false;
|
private static boolean mGlobalSetupDone = false;
|
||||||
|
|
||||||
|
@ -46,9 +46,9 @@ public class DownloadFileTest extends ActivityInstrumentationTestCase2<TestActiv
|
|||||||
private static final String LOG_TAG = DownloadFileTest.class.getCanonicalName();
|
private static final String LOG_TAG = DownloadFileTest.class.getCanonicalName();
|
||||||
|
|
||||||
/* Files to download. These files must exist on the account */
|
/* Files to download. These files must exist on the account */
|
||||||
private static final String IMAGE_PATH = "/fileToDownload.png";
|
private static final String IMAGE_PATH = "/fileToDownload" + Utils.getBuildNumber() + ".png";
|
||||||
private static final String IMAGE_PATH_WITH_SPECIAL_CHARS = "/@file@download.png";
|
private static final String IMAGE_PATH_WITH_SPECIAL_CHARS = "/@file@download" + Utils.getBuildNumber() + ".png";
|
||||||
private static final String IMAGE_NOT_FOUND = "/fileNotFound.png";
|
private static final String IMAGE_NOT_FOUND = "/fileNotFound" + Utils.getBuildNumber() + ".png";
|
||||||
private static final String [] FILE_PATHS = { IMAGE_PATH, IMAGE_PATH_WITH_SPECIAL_CHARS };
|
private static final String [] FILE_PATHS = { IMAGE_PATH, IMAGE_PATH_WITH_SPECIAL_CHARS };
|
||||||
|
|
||||||
private static boolean mGlobalSetupDone = false;
|
private static boolean mGlobalSetupDone = false;
|
||||||
|
@ -43,7 +43,7 @@ public class GetSharesTest extends ActivityInstrumentationTestCase2<TestActivity
|
|||||||
|
|
||||||
private static final String LOG_TAG = GetSharesTest.class.getCanonicalName();
|
private static final String LOG_TAG = GetSharesTest.class.getCanonicalName();
|
||||||
|
|
||||||
private static final String SHARED_FILE = "/sharedFileToGet.txt";
|
private static final String SHARED_FILE = "/sharedFileToGet" + Utils.getBuildNumber() + ".txt";
|
||||||
|
|
||||||
private TestActivity mActivity;
|
private TestActivity mActivity;
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2<TestActivity>
|
|||||||
|
|
||||||
/// Paths to files and folders in fixture
|
/// Paths to files and folders in fixture
|
||||||
|
|
||||||
private static final String SRC_BASE_FOLDER = "/src/";
|
private static final String SRC_BASE_FOLDER = "/src" + Utils.getBuildNumber() + "/";
|
||||||
private static final String TARGET_BASE_FOLDER = "/target/";
|
private static final String TARGET_BASE_FOLDER = "/target" + Utils.getBuildNumber() + "/";
|
||||||
private static final String NO_FILE = "nofile.txt";
|
private static final String NO_FILE = "nofile.txt";
|
||||||
private static final String FILE1 = "file1.txt";
|
private static final String FILE1 = "file1.txt";
|
||||||
private static final String FILE2 = "file2.txt";
|
private static final String FILE2 = "file2.txt";
|
||||||
|
@ -42,7 +42,7 @@ public class ReadFileTest extends ActivityInstrumentationTestCase2<TestActivity
|
|||||||
|
|
||||||
private TestActivity mActivity;
|
private TestActivity mActivity;
|
||||||
|
|
||||||
private String FILE_PATH = "/fileToRead.txt";
|
private String FILE_PATH = "/fileToRead" + Utils.getBuildNumber() + ".txt";
|
||||||
|
|
||||||
public ReadFileTest() {
|
public ReadFileTest() {
|
||||||
super(TestActivity.class);
|
super(TestActivity.class);
|
||||||
|
@ -41,7 +41,7 @@ public class ReadFolderTest extends ActivityInstrumentationTestCase2<TestActivit
|
|||||||
|
|
||||||
private static final String LOG_TAG = ReadFolderTest.class.getCanonicalName();
|
private static final String LOG_TAG = ReadFolderTest.class.getCanonicalName();
|
||||||
|
|
||||||
private static final String FOLDER_PATH = "/folderToRead";
|
private static final String FOLDER_PATH = "/folderToRead" + Utils.getBuildNumber();
|
||||||
private static final String [] FILE_PATHS = {
|
private static final String [] FILE_PATHS = {
|
||||||
FOLDER_PATH + "/file1.txt",
|
FOLDER_PATH + "/file1.txt",
|
||||||
FOLDER_PATH + "/file2.txt",
|
FOLDER_PATH + "/file2.txt",
|
||||||
|
@ -37,7 +37,7 @@ public class RemoveShareTest extends ActivityInstrumentationTestCase2<TestActivi
|
|||||||
|
|
||||||
private static final String LOG_TAG = RemoveShareTest.class.getCanonicalName();
|
private static final String LOG_TAG = RemoveShareTest.class.getCanonicalName();
|
||||||
|
|
||||||
private static final String FILE_TO_UNSHARE = "/fileToUnshare.txt";
|
private static final String FILE_TO_UNSHARE = "/fileToUnshare" + Utils.getBuildNumber() + ".txt";
|
||||||
|
|
||||||
private TestActivity mActivity;
|
private TestActivity mActivity;
|
||||||
|
|
||||||
|
@ -45,15 +45,15 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivit
|
|||||||
private static final String LOG_TAG = RenameFileTest.class.getCanonicalName();
|
private static final String LOG_TAG = RenameFileTest.class.getCanonicalName();
|
||||||
|
|
||||||
/* Folder data to rename. This folder must exist on the account */
|
/* Folder data to rename. This folder must exist on the account */
|
||||||
private static final String OLD_FOLDER_NAME = "folderToRename";
|
private static final String OLD_FOLDER_NAME = "folderToRename" + Utils.getBuildNumber();
|
||||||
private static final String OLD_FOLDER_PATH = FileUtils.PATH_SEPARATOR + OLD_FOLDER_NAME;
|
private static final String OLD_FOLDER_PATH = FileUtils.PATH_SEPARATOR + OLD_FOLDER_NAME;
|
||||||
private static final String NEW_FOLDER_NAME = "renamedFolder";
|
private static final String NEW_FOLDER_NAME = "renamedFolder" + Utils.getBuildNumber();
|
||||||
private static final String NEW_FOLDER_PATH = FileUtils.PATH_SEPARATOR + NEW_FOLDER_NAME;
|
private static final String NEW_FOLDER_PATH = FileUtils.PATH_SEPARATOR + NEW_FOLDER_NAME;
|
||||||
|
|
||||||
/* File data to rename. This file must exist on the account */
|
/* File data to rename. This file must exist on the account */
|
||||||
private static final String OLD_FILE_NAME = "fileToRename.png";
|
private static final String OLD_FILE_NAME = "fileToRename" + Utils.getBuildNumber() + ".png";
|
||||||
private static final String OLD_FILE_PATH = FileUtils.PATH_SEPARATOR + OLD_FILE_NAME;
|
private static final String OLD_FILE_PATH = FileUtils.PATH_SEPARATOR + OLD_FILE_NAME;
|
||||||
private static final String NEW_FILE_NAME = "renamedFile.png";
|
private static final String NEW_FILE_NAME = "renamedFile" + Utils.getBuildNumber() + ".png";
|
||||||
private static final String NEW_FILE_PATH = FileUtils.PATH_SEPARATOR + NEW_FILE_NAME;
|
private static final String NEW_FILE_PATH = FileUtils.PATH_SEPARATOR + NEW_FILE_NAME;
|
||||||
|
|
||||||
|
|
||||||
@ -229,12 +229,14 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivit
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
/*
|
||||||
if (mToCleanUpInServer != null) {
|
if (mToCleanUpInServer != null) {
|
||||||
RemoteOperationResult removeResult = mActivity.removeFile(mToCleanUpInServer);
|
RemoteOperationResult removeResult = mActivity.removeFile(mToCleanUpInServer);
|
||||||
if (!removeResult.isSuccess()) {
|
if (!removeResult.isSuccess()) {
|
||||||
Utils.logAndThrow(LOG_TAG, removeResult);
|
Utils.logAndThrow(LOG_TAG, removeResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,11 +42,11 @@ public class UploadFileTest extends ActivityInstrumentationTestCase2<TestActivit
|
|||||||
|
|
||||||
private static final String LOG_TAG = UploadFileTest.class.getCanonicalName();
|
private static final String LOG_TAG = UploadFileTest.class.getCanonicalName();
|
||||||
|
|
||||||
private static final String UPLOAD_PATH = "/uploadedImage.png";
|
private static final String UPLOAD_PATH = "/uploadedImage" + Utils.getBuildNumber() + ".png";
|
||||||
|
|
||||||
private static final String CHUNKED_UPLOAD_PATH = "/uploadedVideo.MP4";
|
private static final String CHUNKED_UPLOAD_PATH = "/uploadedVideo" + Utils.getBuildNumber() + ".MP4";
|
||||||
|
|
||||||
private static final String FILE_NOT_FOUND_PATH = "/notFoundShouldNotBeHere.png";
|
private static final String FILE_NOT_FOUND_PATH = "/notFoundShouldNotBeHere" + Utils.getBuildNumber() + ".png";
|
||||||
|
|
||||||
|
|
||||||
private TestActivity mActivity;
|
private TestActivity mActivity;
|
||||||
|
@ -30,9 +30,25 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
private static String LOG_TAG = Utils.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final String BUILD_NUMBER_ENV_VAR = "TRAVIS_BUILD_NUMBER";
|
||||||
|
private static String sBuildNumber = null;
|
||||||
|
|
||||||
public static void logAndThrow(String tag, RemoteOperationResult result) throws Exception {
|
public static void logAndThrow(String tag, RemoteOperationResult result) throws Exception {
|
||||||
Log.e(tag, result.getLogMessage(), result.getException());
|
Log.e(tag, result.getLogMessage(), result.getException());
|
||||||
throw new Exception(result.getLogMessage(), result.getException());
|
throw new Exception(result.getLogMessage(), result.getException());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getBuildNumber() {
|
||||||
|
if (sBuildNumber == null) {
|
||||||
|
sBuildNumber = System.getenv(BUILD_NUMBER_ENV_VAR);
|
||||||
|
if (sBuildNumber == null) {
|
||||||
|
Log.w(LOG_TAG, "Build number unknown, using current time instead");
|
||||||
|
sBuildNumber = Long.toString(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sBuildNumber;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user