Repeated Text as Test Data
Repeated text test data is a string made by repeating one short text until it has an exact length. Testers use it to check the length limit of an input field, a form or a database column.
This guide explains how to test a limit at its boundary, what a database does with text that is too long, why characters are not bytes, and which test strings are worth building.
What is repeated text test data?
Repeated text test data is text whose length you know before you use it. One letter repeated 255 times is exactly 255 characters. There is nothing to count afterwards.
- Exact. The length is the length of the text times the count.
- Easy to read. If a field cuts the text, you see at once where it was cut.
- Fast to change. A new length needs only a new count.
If the tool itself is new to you, start with the guide on text repeater meaning.
How to test a length limit
A length limit is tested at its boundary: at the limit, one below it and one above it. Testers call this boundary value analysis. Length bugs often sit at the edge, not in the middle of the range.
A common example from testing guides is a username field that accepts 3 to 30 characters. It is tested with six lengths.
| Length | Expected result | Why this length |
|---|---|---|
| 2 | Rejected | One below the lower limit |
| 3 | Accepted | The lower limit |
| 4 | Accepted | One above the lower limit |
| 29 | Accepted | One below the upper limit |
| 30 | Accepted | The upper limit |
| 31 | Rejected | One above the upper limit |
With a repeater each of these strings is one letter and one count. No one has to type 31 letters and count them.
What a database does with text that is too long
A database either cuts a text that is too long or refuses it. Which one happens depends on its settings, so the test has to check both the form and the stored value.
The MySQL 8.4 Reference Manual gives a clear example for its two common text types.
| CHAR | VARCHAR | |
|---|---|---|
| Length you can declare | 0 to 255 characters | 0 to 65,535 characters |
| Too long, strict SQL mode off | Cut to fit, with a warning | Cut to fit, with a warning |
| Too long, strict SQL mode on | Error, nothing is stored | Error, nothing is stored |
The first case is the dangerous one. The form says "saved", but the end of the text is gone. A repeated string shows this quickly: save 256 letters in a column of 255 and read the value back.
Characters are not bytes
A limit of 100 characters is not always a limit of 100 bytes. In UTF-8, the most common encoding on the web, one character takes from 1 to 4 bytes.
We measured these examples with our own Binary Translator, which shows the number of UTF-8 bytes.
| Text | Characters | UTF-8 bytes |
|---|---|---|
| a | 1 | 1 |
| café | 4 | 5 |
| € | 1 | 3 |
| 😀 | 1 | 4 |
So 100 copies of the letter a are 100 bytes, and 100 copies of one emoji are 400 bytes. If a system counts bytes, the emoji string fails long before the letter string. Test with both.
Test strings you can build with a text repeater
A text repeater builds each of these strings from one short text and one count. Our tool repeats up to 100,000 times and gives a result of up to 2,000,000 characters.
| Goal | Text | Count | Separator | Result |
|---|---|---|---|---|
| Fill a 255 character field | a | 255 | None | 255 characters |
| Go one over the limit | a | 256 | None | 256 characters |
| Test a layout with one long word | a | 500 | None | One word with no place to break |
| Test a list or a text area | line | 1,000 | New line | 1,000 lines |
| Test characters of more than one byte | 😀 | 100 | None | 100 characters, 400 bytes |
| Build about 1 MB of text | 0123456789abcdef | 65,536 | None | 1,048,576 characters |
For a large result, the result box shows only the first 20,000 characters. The Copy and Download .txt buttons give the full text.
How to test without breaking things
- Use a test system. Do not paste very long strings into a live website that other people use.
- Test only what is yours. Long input sent to a system of someone else, without permission, is not testing.
- Start small. Go from the limit to one above it before you try 100,000 characters.
- Read the value back. A saved text can be shorter than the text you sent.
- Clean up. Delete the test records when you are done.
Frequently asked questions
- What is boundary value analysis?
- It is a test method that checks the values at the edge of a range: the limit itself, one below it and one above it.
- How long should a test string be?
- As long as the limit, one shorter and one longer. For a limit of 255 characters, test 254, 255 and 256.
- Can I generate 1 MB of text?
- Yes. Repeat a text of 16 letters or digits 65,536 times without a separator. The result is 1,048,576 characters, which is 1,048,576 bytes in UTF-8.
- Why does my text of 100 characters not fit in a field of 100?
- The system may count bytes. In UTF-8 a letter with an accent takes 2 bytes and an emoji takes 4.
- Is the test text uploaded to your server?
- No. The text is repeated inside your browser and is not sent to our server.