Tech Blog

Testing

How to create dummy files w.r.t different file size for testing in windows

By Shabir shariff1 min read
← Back to blog

During the test, we encounter multiple features that need to be tested against multiple file sizes to ensure verification of the boundary value analysis. 

It’s really easy to generate multiple files with different file sizes using PowerShell;  you may refer to the command below: 

$out = new-object byte[] Value_in_byte; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('OutPut file path', $out)

Value_in_byte: You need to mention the value in byte.
OutPut file path: This refers to the path where the output file should be generated.

Examples

To generate a 1MB file:

$out = new-object byte[] 1048576 ; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('D:\TestData\sample1by.txt', $out)

To generate a 10MB file: 

$out = new-object byte[] 10485760; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('D:\TestData\sample1by.txt', $out)

To generate a 100MB file: 

$out = new-object byte[] 104857600; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('D:\TestData\Sample100mb.txt', $out)

To generate a 1GB file:

$out = new-object byte[] 1073741824; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('D:\TestData\sample1gb.txt', $out)

Note: We can generate any file-type by changing the file extension. 

To generate a 1GB file:

$out = new-object byte[] 1073741824; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('D:\TestData\sample1gb.pdf', $out)

Keep reading

You may be interested in

Browse all articles →
Software Testing: Challenges and Solutions
February 8, 20244 min read

Software Testing: Challenges and Solutions

Introduction – Testing software is a crucial aspect of the development process. It makes sure that the product’s functionality works as expected, fulfills the user requirements, and makes sure it works without errors. In this blog, we will list down some of the most common challenges faced in software testing and conclude with how to […]

By Saboor ChandshahaRead More →
Streamlining Software Quality: The Power of Automating Black Box Testing
February 8, 20244 min read

Streamlining Software Quality: The Power of Automating Black Box Testing

Introduction :  In the dynamic realm of software development, ensuring the robustness and reliability of applications is of paramount importance. Black box testing, a technique that assesses software functionality without requiring knowledge of its internal code, plays a vital role in identifying potential defects. As the complexity of software systems continues to escalate, the manual […]

By Anthony Gilchrist G SRead More →
Implementing best practices for end-to-end testing in cloud migration
January 31, 20245 min read

Implementing best practices for end-to-end testing in cloud migration

Importance of End-to-End Testing Assume an organization’s core systems are now hosted on the cloud—a complex ecosystem linked by data threads. End-to-end testing is the foundation upon which the reliability and performance of this interconnected web is built. This rigorous testing technique makes it possible to detect vulnerabilities, optimize operations, and improve user experience. Active […]

By Rahul ChakravartiRead More →