Class DumpFileAsserts
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.DumpFileAsserts
-
public class DumpFileAsserts extends Object
Helper class to enable assertions based on golden-data dump files.Allows the golden files to be easily updated with new data (see more info in the docs on
DUMP_FILE_ACTION).Compatible with
Dumper.Dumpablebut can also be used directly with Strings generated through different means.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_TEST_ASSET_DIRECTORYThe default test asset directory used if no other directory is specified.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertOutput(Context context, Dumper.Dumpable actual, String dumpFile)Asserts that the dump output ofactualis equal to the contents ofdumpFilein theDEFAULT_TEST_ASSET_DIRECTORY.static voidassertOutput(Context context, Dumper.Dumpable actual, String assetDirectory, String dumpFile)Asserts that the dump output ofactualis equal to the contents ofdumpFilein theassetDirectory.static voidassertOutput(Context context, String actual, String dumpFile)static voidassertOutput(Context context, String actual, String assetDirectory, String dumpFile)Asserts thatactualis equal to the contents ofdumpFileinassetDirectory.
-
-
-
Field Detail
-
DEFAULT_TEST_ASSET_DIRECTORY
public static final String DEFAULT_TEST_ASSET_DIRECTORY
The default test asset directory used if no other directory is specified.- See Also:
- Constant Field Values
-
-
Method Detail
-
assertOutput
public static void assertOutput(Context context, Dumper.Dumpable actual, String dumpFile) throws IOException
Asserts that the dump output ofactualis equal to the contents ofdumpFilein theDEFAULT_TEST_ASSET_DIRECTORY.If the assertion fails because of an intended change in the output or a new dump file needs to be created, set
DUMP_FILE_ACTIONtoWRITE_TO_LOCALfor local tests and toWRITE_TO_DEVICEfor instrumentation tests, and run the test again. Instead of assertion,actualwill be written todumpFile. For instrumentation tests, this new dump file needs to be copied to the project asset folder manually.- Parameters:
context- A context.actual- The actual data.dumpFile- The file path of the dump file in the assets directory.- Throws:
IOException
-
assertOutput
public static void assertOutput(Context context, Dumper.Dumpable actual, String assetDirectory, String dumpFile) throws IOException
Asserts that the dump output ofactualis equal to the contents ofdumpFilein theassetDirectory.If the assertion fails because of an intended change in the output or a new dump file needs to be created, set
DUMP_FILE_ACTIONtoWRITE_TO_LOCALfor local tests and toWRITE_TO_DEVICEfor instrumentation tests, and run the test again. Instead of assertion,actualwill be written todumpFile. For instrumentation tests, this new dump file needs to be copied to the project asset folder manually.- Parameters:
context- A context.actual- The actual data.assetDirectory- The directory of the assets relative to the project working directory. Only used whenDUMP_FILE_ACTIONis set toWRITE_TO_LOCAL.dumpFile- The file path of the dump file in the assets directory.- Throws:
IOException
-
assertOutput
public static void assertOutput(Context context, String actual, String dumpFile) throws IOException
Asserts thatactualis equal to the contents ofdumpFilein theDEFAULT_TEST_ASSET_DIRECTORY.If the assertion fails because of an intended change in the output or a new dump file needs to be created, set
DUMP_FILE_ACTIONtoWRITE_TO_LOCALfor local tests and toWRITE_TO_DEVICEfor instrumentation tests, and run the test again. Instead of assertion,actualwill be written todumpFile. For instrumentation tests, this new dump file needs to be copied to the project asset folder manually.- Parameters:
context- A context.actual- The actual data.dumpFile- The file path of the dump file in the assets directory.- Throws:
IOException
-
assertOutput
public static void assertOutput(Context context, String actual, String assetDirectory, String dumpFile) throws IOException
Asserts thatactualis equal to the contents ofdumpFileinassetDirectory.If the assertion fails because of an intended change in the output or a new dump file needs to be created, set
DUMP_FILE_ACTIONtoWRITE_TO_LOCALfor local tests and toWRITE_TO_DEVICEfor instrumentation tests, and run the test again. Instead of assertion,actualwill be written todumpFile. For instrumentation tests, this new dump file needs to be copied to the project asset folder manually.- Parameters:
context- A context.actual- The actual data.assetDirectory- The directory of the assets relative to the project working directory. Only used whenDUMP_FILE_ACTIONis set toWRITE_TO_LOCAL.dumpFile- The file path of the dump file in the assets directory.- Throws:
IOException
-
-