Types of Files Used in Android Mobile Testing - Notes By ShariqSP
Types of Files Used in Android Mobile Testing
In Android mobile testing, external files are used to provide test data, configurations, or expected outcomes. Below are the common file types and their uses:
-
XML Files
- Purpose: Often used for structured test data and configuration files.
- Advantages: Well-suited for hierarchical data, easily parsed using libraries like
XmlPullParser,SAXParser, orDOM. - Examples: Test configurations, UI layouts for testing.
-
JSON Files
- Purpose: Widely used for test data due to its simplicity and human-readability.
- Advantages: Lightweight, easily parsed using libraries like
GsonorJackson. - Examples: API responses, input data for form testing.
-
CSV Files
- Purpose: Used for tabular data, such as test cases or parameterized test inputs.
- Advantages: Simple structure, easy to manage large datasets.
- Parsing: Can be read using libraries like
Apache Commons CSVor manually split usingString.split().
-
Excel Files (XLS/XLSX)
- Purpose: Used for maintaining extensive datasets or detailed test cases.
- Advantages: Highly structured, can include multiple sheets for categorizing data.
- Parsing: Read using libraries like
Apache POIorJExcel.
-
Text Files (TXT)
- Purpose: Used for unstructured or simple key-value data.
- Advantages: Easy to create and edit, low overhead.
- Parsing: Use standard file I/O operations.
-
Property Files
- Purpose: Used for storing configuration details in a key-value format.
- Advantages: Easy to read and modify, standard support in Java using the
Propertiesclass. - Examples: Environment configurations, credentials.
-
YAML Files
- Purpose: Used for configuration and data files with a readable format.
- Advantages: Human-readable, supported by libraries like
snakeyaml. - Examples: Configuration and test data.
-
Database Files
- Purpose: Local databases like SQLite are used for testing database interactions.
- Advantages: Handles large datasets, realistic data testing.
- Access: Use
SQLiteDatabaseor libraries like Room.
-
Custom Binary Files
- Purpose: Used for specific application data formats.
- Advantages: Compact data storage, application-specific needs.
- Parsing: Custom parsers are required based on the binary format.
Choosing the Right File Type:
- For structured data: Use JSON or XML.
- For tabular data: Use CSV or Excel.
- For configuration: Use Properties or YAML.
- For large datasets: Use SQLite or external database files.