How to Write Email Validation Test Cases

How to Write Email Validation Test Cases

Are you struggling with writing email validation test cases? It’s time to show those pesky typos who’s boss. In this blog, I’ll provide tips and tricks on how to write effective email validation test cases. Get ready to take your email testing game up a notch!

Introduction

Email validation tests are designed to ensure that an email address is correctly entered and formatted correctly. These tests are used to verify whether an email address will pass validation checks, such as checking for the correct syntax and domains, making sure that the email is properly formatted, and checking for unwanted characters.

Email validation tests are important because they help improve the accuracy of your data entries and provide a higher level of security for sensitive data, such as passwords or credit card details.

Writing effective test cases for email validation can be challenging but rewarding when done correctly; it requires a thorough understanding of the data being tested. In this guide, we will discuss various key elements of writing effective test cases for validating emails including:

  • Determining the type of tests needed;
  • Developing steps to execute the necessary test activities;
  • Creating data-driven pre-condition rules and post-condition assertions;
  • Using built-in assertion methods to validate emails;
  • Creating mock emails to use in testing scenarios; and
  • Finally reporting on results.

By following these guidelines you should be able to quickly create meaningful test cases that can aid in verifying your application’s email validation process.

Understanding Email Validation

Email validation is a process of verifying that an email address exists and is valid, whether it is in a web form or as part of user account creation. It allows businesses, online services and websites to ensure that the information they receive from their customers is valid.

Email validation tests need to be written carefully to make sure that only valid emails pass your test cases. To start, it’s important to understand the anatomy of an email address—which includes the username, @-sign, domain name, dot (.), and top-level domain (TLD). First and foremost, any email validation test must check for these five pieces of information in order to validate if an email address is indeed valid or not. Additionally, special characters like dashes (-) or underscores (_) should also be accounted for in the username within your test cases.

The other aspect of email validation tests is to verify:

  • if a particular domain name exists;
  • if a typical format such as x@y.z has been followed; and
  • if the username entered does not contain invalid characters such as apostrophes (‘).

The most comprehensive way for companies to do this kind of validation is by querying an SMTP server to check whether the given user actually exists at the specified domain—that would mean that it’s more likely for you receive communications from them since their account does exist on a mail server.

Finally, it’s important for companies to be aware of any internationalization issues when writing their email validation tests. Foreign users may sometimes use different character sets like Cyrillic or Greek instead of Latin ones found in English characters—companies must consider those scenarios while developing their own tests so they do not accidentally filter out valid emails written with those character sets.

Types of Email Validation

When it comes to testing email validation within software applications, there are certain types of tests that should be conducted. These test cases are designed to verify that the email address provided is valid, and whether or not it meets the criteria laid out by standards and/or regulations. Below are common types of email validation tests that can be done.

  • General Format: One of the basic email validation checks is to verify if the address provided contains a valid syntax or format. Tests should include making sure an @ symbol is present, along with other characters such as periods, hyphens and underscores in the address fields. All emails should also follow specific length parameters as set by internet standards and other applicable regulations.
  • Domain-Specific Validation: Domain-specific validation involves testing the domain name portion of an email address to see whether or not it can accept incoming emails from other servers. This test helps to assess a domain’s capability to receive messages sent from outside sources and will tend to target certain character strings in the domain portion of an address.
  • Syntactical Validity Test: A syntactical validity test checks characters like periods, hyphens and even spaces within each portion of an email’s format (local-part/domain part) for accuracy. This type of check helps detect any typing errors that may have been made while entering in a personal email address. It also tests validity against organizational conventions like maximum character limits per section (e.g., username@companyname(maxlength).com).
  • DNS Validity Test: Often called “MX record” testing, this type of check evaluates whether or not a domain name listed on an email exists on a public DNS registry. It determines whether or not individual domains exist online when classified against top-level domains (TLD) such as .org, .net, etc., and second-level domains (SLD) like google mail (GMail). Results gleaned from these checks help validate an entry field’s ability to receive emails from external sources successfully.

Writing Test Cases for Email Validation

Creating test cases for email validation is a vital part of validating input in forms and ensuring that the system is not vulnerable to attack. While there are many methods to do this, the following guidelines should help you create complete test cases that cover all aspects of email validation.

First and foremost, it is important to understand the rules of validating an email address. For example, an email address must have at least one @ symbol and at least one full stop (or period) after the @ symbol has been used. The domain name must also be included after the full stop, as well as a two-character top level domain such as .com or .net.

Once these rules have been understood a comprehensive set of test cases can be developed. These should include boundary value tests that check addresses with each rule set (that is, tests which include no @ symbol or no full stop). In addition, random inputs such as invalid characters and strings should be tested to determine how resilient software or websites are when validating emails.

Lastly, on-demand parameters can be tested for additional resilience with some software allowing users to enter up to five different email addresses with various input methods being used regarding special characters (such as: , _ etc.). It’s always beneficial to provide a list of valid inputs such as those outlined in RFC 5322 and validate them against user input within forms or profiles on websites. This can help reduce common errors arising from incorrect use of syntax.

Designing Test Scenarios for Email Validation

Designing test scenarios for email validation is an important part of developing quality software. In order for tests to adequately cover valid input and reject invalid input, the test designer should consider various aspects of email address syntax. This may include:

  • Formatting: verifying that all email addresses comply with accepted formats and are syntactically correct.
  • Presence of certain characters: ensuring certain characters (e.g. “@”, “.”) are present in the right places, with extra characters correctly rejected;
  • Length: verifying that no restriction was applied to the maximum length of an email address.
  • Domain type: ensuring domain type (e.g. .com) is supported.
  • Automatic name resolution: checking if a name resolution was done automatically or not.
  • Completness of subdomain name elements: verifying that all subdomain name elements (such as lhs, mhs) were included.
  • Country code top level domains (CCTLD): verifying if country code domains such as .ca, .de are accurately processed and validating their codes/symbology complexities.
  • Validity of emails at server side : checking if there is validity checks at the server side too which will require us sending raw emails strings to the server via API calls & then validate responses from it.

Additionally, during testing, attention should be paid to input cases related to internationalization such as national character support or using alpha-2 country codes instead of names – since these can vary from one language/country region to another. As each scenario is designed and tested, so measures can be taken to ensure its robustness and data integrity regarding email validation processes throughout a system implementation life cycle.

Testing Email Validation

Email validation is an important process for website validation and general software testing. While basic email syntax is usually straightforward enough to implement, more complex rules such as maximum character lengths, bans on certain TLD (top level domain) names, or different verification methods for certain countries can make it more challenging to handle properly.

It’s important to make sure any email selection processes within the application have adequate test coverage. There are a few areas that should be covered when writing email validation test cases:

  • Formatting: Verify that the email address contains all of the components required by RFCs 822 and 853 (for example local part, @ sign, domain name).
  • Length: Test that any maximum length restrictions are enforced appropriately. This includes the local part being under 64 characters long, and the entire address being no longer than 254 characters long.
  • Banned domains: Ensure that domains which have been banned from certain functions are correctly rejected (e.g., will not accept .ru or .co domains < both banned in some applications).
  • Disallowed characters: Validate that addresses can only contain alphanumeric characters, hyphens and periods in appropriate places only. Spaces or other special characters check should be undertaken if they would normally be accepted by the system but then rejected elsewhere within the application.
  • Verification method by country of origin: Test different email verification methods depending on where the user is signing up from – some countries may require SMS verification as well as standard confirmation emails sent out upon registration purposes.

Common Pitfalls in Email Validation Testing

Email validation testing is an important part of ensuring that an application or system can process emails correctly. To ensure accuracy and reliability, it is important to be aware of the common pitfalls associated with email validation testing.

First, it is essential that testers have a complete understanding of what constitutes a valid email address. Email addresses are made up of two parts: the user name (before the @ symbol) and the domain name (after the @ symbol). Common formatting errors that lead to email addresses being rejected include:

  • Incomplete strings
  • Invalid characters
  • Invalid domain names
  • Incorrect ordering of characters
  • Duplicate information
  • Keyed-in typos which can all result in emails not being processed properly.

Second, attention must also be paid to edge cases such as internationalized email addresses with different character sets and alternate top-level domains such as .club or .net which are becoming increasingly popular. Depending on how your software handles them, test cases should incorporate both domestic and international domains to ensure maximum compatibility.

Finally, you should also be aware of any additional logic built into your system such as auto-completion or blacklisted words/phrases; these features may also need to be tested for accuracy and reliability. By taking these common pitfalls into consideration during your test planning process you can save yourself time and energy when making sure that emails are validated successfully within your software or application.

Conclusion

In conclusion, email validation is an important part of any software development project as it ensures that any given email address is authentic. Writing effective test cases for email validation requires thorough testing strategies, coverage of all the scenarios and secure data input.

From simply ensuring that the user input is of a valid length to checks for illegal characters, testing should be across multiple combinations of test data. In addition, proper documentation should always be in place so that all the scenarios and assumptions can be mapped out and agreed upon by all involved parties.

By following these guidelines in your own project, you will ensure that your email validation process is secure and reliable.

Frequently Asked Questions

Q1. What is Email Validation?
A1. Email Validation is a process that ensures an email address is valid and exists. It also checks if the domain name of the email address is valid and active.

Q2. What is the purpose of Email Validation Test Cases?
A2. Email Validation Test Cases are used to test the accuracy of an email address. It checks if the email address is valid and if the domain name is active.

Q3. What are some important email validation test cases?
A3. Important email validation test cases include checking the format of the email address, making sure the domain name is valid and active, and checking if the email address is already in use.

How To Solve Issues With Email Checker API

An email checker API allows you to validate email addresses effortlessly. So, you can reach real customers. But can it really stop spammers effectively? Your database contains a huge number of email IDs. Can the API keep your mailing list clean with authentic IDs efficiently? There are lots of other problems, including potential security threats.

Can you really solve all these issues effectively with an email checker API? In this post, you will find all the details.

What is an email checker API?

An email checker API is a tool for verifying the email addresses on your mailing list efficiently. It helps identify IDs owned by real people. So, you can get access to genuine clients and grow your business effectively. It utilizes advanced features, like typos check, SMTP check, and disposable email ID detection, to ensure the deliverability of your mailing list.

Why should I use an email checker API?

  • Effectively improve email deliverability
  • Significantly reduce bounce rate
  • Protect your sender reputation so that your emails will never end up in the junk folder
  • Save time and money by automating the validation process
  • Keep your mailing list clean with authentic and genuine email addresses

How can I solve issues with an email checker API?

Which issues can you solve with the email verification API? Let’s take a look at some practical examples.

Prevent typos on registration and sign-up forms

One of the most common uses of an email checker API is to prevent typos in sign-up forms. New users are required to enter their email addresses. By enabling the API during the registration, you can help the form spot typos instantly. The users will receive an alert about their mistakes. So, they can make necessary corrections immediately.

If you are using Mailboxlayer for detecting typos, you will get an alternative email suggestion within the API result. Here is an example:

{
  "email": "user@gnail.com",
  "did_you_mean": "user@gmail.com",
  [...]
}

Here, the given email address is user@gnail.com. As you can see, the ID has a typo, which is “gnail.” It should be “gmail.” So, Mailboxlayer suggests an alternative email address with the correct spelling through the “did_you_mean” field.

Identify disposable email addresses easily to stop spammers

Disposable email addresses are widely abused by spammers. They get temporary email IDs from different providers, like Mailinator. Spammers use the addresses for fake sign-ups and to perform fraudulent activities. By utilizing an email checker API, you can identify the disposable email address effortlessly. Let’s try verifying this email address:

support@apilayer.com

Let’s make an API request by passing the email address and the API access key:

https://apilayer.net/api/check
    ? access_key = YOUR_ACCESS_KEY
    & email = support@apilayer.com

You will get this response:

{
  "email": "support@apilayer.com",
  "did_you_mean": "",
  "user": "support",
  "domain": "apilayer.net",
  "format_valid": true,
  "mx_found": true,
  "smtp_check": true,
  "catch_all": false,
  "role": true,
  "disposable": false,
  "free": false,
  "score": 0.8
}

As you can see, the disposable field is set to false. So, the given ID is not from a disposable email address provider.

Also, you can use Mailboxlayer to check the roles of email addresses. You can find the details right here.

Validate a large number of email addresses

The email checker API allows you to perform bulk email address validation. So, you can easily verify a large number of IDs.

If you are using Mailboxlayer, you simply need to append multiple comma-separated email addresses to the API’s base URL. Here is an example:

https://apilayer.net/api/check
        ? access_key = YOUR_ACCESS_KEY
        & email = support@apilayer.com, support1@apilayer.com,
        support2@mailboxlayer.com, ...

As you can see, Mailboxlayer makes it very easy to validate many email IDs. There is no hassle. So, you can perform the bulk email address verification effortlessly.

The API marketplace by Apilayer also provides a suite of highly efficient APIs. It can help you to boost your productivity significantly. Try it now for free. 

Verify email IDs in real-time

The email checker API supports the real-time email address validation feature. It allows you to verify email IDs as they are typed into the registration form. In this way, you can prevent spammers from signing up to your website in real-time.

Mailboxlayer utilizes MX-record lookup and SMTP verification technologies to perform real-time verification. The API checks whether the domain of the given email address is configured to receive emails. If Mailboxlayer finds it in the MX records, you will receive this response:

{
  [...]
  "mx_found": true,
  [...]
}

mx_found field is set to true. So, the email address is valid. If it was invalid, mx_found would have been set to false.

Next, Mailboxlayer performs the SMTP check. If the given address is valid, you will get this response:

{
  [...]
  "smtp_check": true,
  [...]
}

If the email ID was invalid, the smtp_check field would have been set to false.

Securely validate my mailing list

An email checker API features a variety of technologies for protecting your mailing list from potential security threats. For example, Mailboxlayer comes with the industry-standard 256-bit encryption technology. It prevents hackers from intruding on your system while establishing the connection between the API. You just need to attach an “s” to the HTTP protocol. That means you will have to type https://, rather than http://. It will allow the system to utilize SSL for encrypting normal HTTP requests and responses.

Can Mailboxlayer efficiently solve my issues?

Mailboxlayer is a powerful email checker API. It can help identify typos during the registration. It can perform the validation in real-time. Also, Mailboxlayer can verify a large number of email addresses effortlessly. You will never have to worry about potential security threats, thanks to the 256-bit encryption technology. Additionally, it can identify disposable email addresses to stop the spammers. So, you can definitely rely on Mailboxlayer for solving your issues efficiently.

Mailboxlayer is a simple REST API for performing email address validation. It is powerful, secure, and very easy to use.
Try it now for free!

How to Write Email Validation Test Cases

This tutorial will show you how to create email validation test cases. Many applications will collect your email ID. You can purchase tickets, schedule an appointment, and book online on eCommerce sites. All testers should be able to create validation scenarios for email addresses.

The email field is where you send a message to someone. The subject usually includes the sender’s name and the receiver’s. This field can also be used to write other messages or images.

Before we can start our test case, it is important to establish the Acceptance Criteria

What is the Acceptance Criteria in email address validation cases?

We must have functional requirements, as we discussed in requirements post. Let’s define them.

Description: The user must be able enter their email id when they register their account.

Abbreviated Acceptance Criteria

What are the test cases for email address validation?

Positive Scenarios:

  1. Verify the input field accepts a valid email address. Some examples:
    1. example@email.com
    2. example.first.middle.lastname@email.com
    3. example@subdomain.email.com
    4. example+firstname+lastname@email.com
    5. example@234.234.234.234
    6. example@[234.234.234.234]
    7. “example”@email.com
    8. 0987654321@example.com
    9. example@email-one.com
    10. _______@email.com
    11. example@email.name
    12. example@email.museum
    13. example@email.co.jp
    14. example.firstname-lastname@email.com
    15. Valid Email Addresses that appear at glance to be invalid
    16. extremely.”odd\unusual”@example.com
    17. extremely.unusual.”@”.unusual.com@example.com
    18. very.”(),:;<>[]”.VERY.”very@\\ “very”.unusual@strange.email.example.com
  2. Verify email id can contain a dot in the address field.
  3. Verify email id can contain a dot in the subdomain field.
  4. Verify email id can contain a plus sign.
  5. Verify email id can contain an IP address in square bracket.
  6. Verify email id can contain quotes.
  7. Verify email id can contain digits.
  8. Verify email id can contain an underscore.
  9. Verify email id with a valid top-level domain name is valid.
  10. Verify top-level domain can contain a dot.
  11. Verify email id with a dash is considered valid.

Negative Scenarios:

As with all test scenarios, there do exist some negative scenarios you will want to verify. Namely:

  1. Verify an email id cannot exceed 254 characters.
  2. Verify the missing @ symbol in the email id field.
  3. Verify the missing domain in the email id field.
  4. Verify gibberish or garbage is not accepted in the email id text box.
  5. Verify the missing username in the email id field.
  6. Verify encoded HTML within the email id field is invalid.
  7. Verify leading dot in the email id text box is invalid.
  8. Verify trailing dot in the email id text box is invalid.
  9. Verify multiple dots in the email field.
  10. Verify unicode char in the address in the email text box.
  11. Verify invalid IP address format in the email text box.
  12. Verify multiple dots in the domain is invalid.
  13. Verify invalid email addresses like these:
    1. plaintext address
    2. @#@@##@%^%#$@#$@#.com
    3. @email.com
    4. John Doe <example@email.com>
    5. example.email.com
    6. example@example@email.com
    7. .example@email.com
    8. example.@email.com
    9. example…example@email.com
    10. おえあいう@example.com
    11. example@email.com (John Doe)
    12. example@email
    13. example@-email.com
    14. example@email.web
    15. example@111.222.333.44444
    16. example@email…com
    17. CAT…123@email.com
    18. ”(),:;<>[\]@email.com
    19. obviously”not”correct@email.com
    20. example\ is”especially”not\allowed@email.com

Test Diminishing Returns

Remember that testing has diminishing returns and developers should use a well-tested library or regex to test this functionality. These are just a few tests that people might want to run but they are not necessary.

  1. Too many symbols (@). must be verified
  2. Verify all domains at the top.
  3. Verify that there are no top-level domains.

As a tester, it’s important to discuss with the developer what the library code does and doesn’t do. This will help you target your testing efforts for testing email addresses.

FAQ

What is the validation for email?

Email validation is a method to determine if an email address can be reached and is valid. It quickly detects typos and determines whether they are genuine errors or intentional misdirection. It checks whether an email address is associated to a trusted domain.

Test Cases For Search Functionality

The search function in the app enables users to search digital objects in the collection through simple search or advanced search.

A search function that searches your Web pages can be a great design strategy to help users find the content they are looking for. Searches for keywords or phrases can help users find content without having to navigate the site’s structure. This is a faster and easier way to locate content, especially on large sites.

How to test search functionality. Test Case:

  1. Verify the search field present and aligned.
  2. Verify place holder text added on search or not.
  3. Verify spelling and grammar should be correct for place holder text.
  4. Verify search icon is present on the field.
  5. Verify cursor should present on click on the search icon.
  6. Verify search is functional and generating the correct result for correct keywords or not by adding valid search.
  7. Verify if the user can paste the keyword with the mouse.
  8. Verify search working by adding keywords and on click on the search button.
  9. Verify search working by adding keywords and pressing the Enter key from the keyboard.
  10. Verify an error message display by entering invalid keywords in the search field and clicking the search button.
  11. Verify a loader added if take time to get the result.
  12. Verify an error message should display for blank input.
  13. Verify and observe how much time required for getting the search result.
  14. Verify pagination added in case if the search result goes on the number of pages.
  15. Verify pagination is accessible or not by clicking on the Next, Previous and number.
  16. Verify the search result generated by the search in the correct order as per requirement.
  17. Verify the max and min range for the search keyword.
  18. Verify auto suggestion shown on adding a keyword or not.
  19. Verify suggestions shown or not on adding a keyword to search.
  20. Verify related keywords added to the search result or not. It should be added.
  21. Verify if new items/tools added on the website, a keyword should also be for the website search. So, the user can access them.

Why do we use search function?

This ensures website visitors can find the information they are looking for faster and makes it easier to make a purchase. An online shop owner’s USP can be a strong search function, which helps him stand out among his competitors.

How do I add Google search functionality to my website?

Add custom search to your site:

  1. From the control panel, select the search engine you want to edit.
  2. Click Setup from the menu on the left and then click the Basics tab.
  3. Click Get code.
  4. Copy the code and paste it into your site’s HTML source code where you want your search engine to appear.

The Detailed guide is read here.

VWO: Reviews, Testimonials and Expert Opinions

All-in-One A/B Testing and Conversion Optimization Platform

VWO is the market-leading A/B testing tool that fast-growing companies use for experimentation & conversion rate optimization. Website.

VWO Overview

VWO Optimization Platform helps to improve key business metrics by empowering to easily discover insights, test ideas, and improve engagement across the entire customer journey. It helps to improve sales and revenue and acquire customers.

VMO enables to optimize the entire audience journey by optimizing both web and messaging experiences, uncovering blockages in the customer journey using VWO insights, gathering, and organizing the insights in the VWO plan, collaborating with the team to convert them into data-backed hypotheses and prioritizing and execute the optimization roadmap through VWO testing.

It helps to continuously improve KPIs including features like conversion growth by rapidly testing tons of new ideas, diagnosing problem areas in the visitors’ experiences, keeping the visitors engaged with automated marketing campaigns through web push notifications, and Facebook Messenger and many more.

Testing PDF content with PHP and Behat

If you have a PDF generation functionality in your app, and since most of the libraries out there build the PDF content in an internal structure before outputting it to the file system (FPDF, TCPDF). A good way to write a test for it is to test the output just before the rendering process.

Recently however, and due to this process being a total pain in the ass, people switched to using tools like wkhtmltopdf or some of its PHP wrappers (phpwkhtmltopdfsnappy) that let you build your pages in html/css and use a browser engine to render the PDF for you, and while this technique is a lot more developer friendly, you loose control over the building process.

So if you’re using one of those tools or just need to test for the existence of some string inside a PDF, here’s how to write a BDD style acceptance test for it using Behat.

Setup framework

Add this your composer.json then run composer install

{
    "minimum-stability": "dev",
    "require": {
        "smalot/pdfparser": "*",
        "behat/behat": "3.*@stable",
        "behat/mink": "1.6.*@stable",
        "phpunit/phpunit": "4.*"
    },
    "config": {
        "bin-dir": "bin/"
    }
}

Initialize Behat

bin/behat --init

This command creates the initial features directory and a blank FeatureContext class.

If everything worked as expected, your project directory should look like this :

├── bin
│   ├── behat -> ../vendor/behat/behat/bin/behat
│   └── phpunit -> ../vendor/phpunit/phpunit/phpunit
├── composer.json
├── composer.lock
├── features
│   └── bootstrap
└── vendor
    ├── autoload.php
    ├── behat
    ├── composer
    ├── doctrine
    ├── phpdocumentor
    ├── phpspec
    ├── phpunit
    ├── sebastian
    ├── smalot
    ├── symfony
    └── tecnick.com

All right, it’s time to create some features, create a new file inside /feature, I’ll name mine pdf.feature

Feature: Pdf export
 
  Scenario: PDF must contain text
    Given I have pdf located at "samples/sample1.pdf"
    When I parse the pdf content
    Then the the page count should be "1"
    Then page "1" should contain
    """
Document title  Calibri : Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    """

Run Behat (I know we didn’t write any testing code yet, just run it, trust me!)

bin/behat

An awesome feature of Behat is it detects any missing steps and provides you with boilerplate code you can use in your FeatureContext. This is the output of the last command:

Feature: Pdf export
 
  Scenario: PDF must contain text                     # features/pdf.feature:3
    Given I have pdf located at "samples/sample1.pdf"
    When I parse the pdf content
    Then the the page count should be "1"
    Then page "1" should contain
      """
      Document title  Calibri : Lorem ipsum dolor sit amet, consectetur adipiscing elit.
      """
 
1 scenario (1 undefined)
4 steps (4 undefined)
0m0.01s (9.28Mb)
 
--- FeatureContext has missing steps. Define them with these snippets:
 
    /**
     * @Given I have pdf located at :arg1
     */
    public function iHavePdfLocatedAt($arg1)
    {
        throw new PendingException();
    }
 
    /**
     * @When I parse the pdf content
     */
    public function iParseThePdfContent()
    {
        throw new PendingException();
    }
 
    /**
     * @Then the the page count should be :arg1
     */
    public function theThePageCountShouldBe($arg1)
    {
        throw new PendingException();
    }
 
    /**
     * @Then page :arg1 should contain
     */
    public function pageShouldContain($arg1, PyStringNode $string)
    {
        throw new PendingException();
    }

Cool right? copy/paste the method definitions to you FeatureContext.php and let’s get to it, step by step :

Step 1

Given I have pdf located at "samples/sample1.pdf"

In this step we only need to make sure the filename we provided is readable then store it in a class property so we can use it in later steps:

 /**
     * @Given I have pdf located at :filename
     */
    public function iHavePdfLocatedAt($filename)
    {
        if (!is_readable($filename)) {
            Throw new \InvalidArgumentException(
                sprintf('The file [%s] is not readable', 
                $filename)
            );
        }
 
        $this->filename = $filename;
    }

Step 2

When I parse the pdf content

The heavy lifting is done here, we need to parse the PDF and store its content and metadata in a usable format:

    /**
     * @When I parse the pdf content
     */
    public function iParseThePdfContent()
    {
        $parser = new Parser();
        $pdf    = $parser->parseFile($this->filename);
        $pages  = $pdf->getPages();
        $this->metadata = $pdf->getDetails();
 
        foreach ($pages as $i => $page) {
            $this->pages[++$i] = $page->getText();
        }
    }

Step 3

Then the the page count should be "1"

Since we already know how many pages the PDF contains, this is a piece of cake, so let’s not reinvent the wheel and use PHPUnit assertions:

 /**
     * @Then the the page count should be :pageCount
     * @param int $pageCount
     */
    public function theThePageCountShouldBe($pageCount)
    {
        PHPUnit_Framework_Assert::assertEquals( 
            (int) $pageCount, 
            $this->metadata['Pages']
        );
    }

Step 4

Then page "1" should contain
    """
Document title  Calibri : Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    """

Same method, we have an array containing all content from all pages, a quick assertion does the trick:

    /**
     * @Then page :pageNum should contain
     * @param int $pageNum
     * @param PyStringNode $string
     */
    public function pageShouldContain($pageNum, PyStringNode $string)
    {
        PHPUnit_Framework_Assert::assertContains(
            (string) $string, 
            $this->pages[$pageNum]
        );
    }

Et voilà! you should have green

Feature: Pdf export
 
  Scenario: PDF must contain text                     # features/pdf.feature:3
    Given I have pdf located at "samples/sample1.pdf" # FeatureContext::iHavePdfLocatedAt()
    When I parse the pdf content                      # FeatureContext::iParseThePdfContent()
    Then the the page count should be "1"             # FeatureContext::theThePageCountShouldBe()
    Then page "1" should contain                      # FeatureContext::pageShouldContain()
      """
      Document title  Calibri : Lorem ipsum dolor sit amet, consectetur adipiscing elit.
      """
 
1 scenario (1 passed)
4 steps (4 passed)

For the purpose of this article, we’re relying on the PDF parser library which has many encoding and white space issues, feel free to use any PHP equivalent or a system tool like xpdf for better results.

If you want to make your test more decoupled (and you should). One way is to create a PDFExtractor interface then implement it for each tool you want to use, that way you can easily swap libraries.

The source code behind this article is provided here, any feedback is most welcome.

Source: matmati.net:80/testing-pdf-with-behat-and-php

How to Find Over 200+ Beta Testers for Free

Beta testing: the rehearsal before showcasing your app to the world. The beta testing phase is a critical one in your app’s life cycle and you need to make the most of it. Finding beta testers is an integral part of this process. You need them to test your app in every possible way to make sure that you weed out all the hidden corner case bugs. But where can you find these beta users and how many of them would be willing to try out your app? We’ll tell you where you can find these users and, lucky for you, there are tons of early adopters out there who would love to try out your app — and for free!

 

 

First, how many beta testers do you need?

 

A very important question that depends on the size and scope of your application. This number largely depends on the number of features and demographic characteristics of the app and its users (Beta Testing Guide). To be on the safe side, you’ll need between 100-300 beta testers to make sure your users go through all the use cases necessary to ensure your app is clean.

 

 

Where can you find these beta testers?

 

We’ve done the hard work for you and compiled a list of sources — use them!

A great way to get feedback on your product is to put it in front of a bunch of people who have already expressed a desired interested in a specific domain. You can leverage various forums and social media as platforms for displaying your product. However, you need to remember you should be a part of their community or else you will be perceived as a spammer or even worse: an advertiser.

 

1. HACKER NEWS

By far the biggest online grouping of tech enthusiasts in the Internet universe is Hacker News. If you’re looking for honest and brutal feedback, you won’t find a better place. This is where the smartest and most influential people in the tech world hang out, so it’s still definitely worth it because if you make it on HN, you’ve basically made it in life. Check out how to craft a successful HN post and don’t ever forget to follow the rules!

 

2. REDDIT

You may not think they have the most enjoyable user interface but they do have a passionate and extremely involved community. Just like HN, Reddit has its own dedicated community and usually welcomes those with karma with an open heart. The good thing about Reddit is that you’ll find a subreddit for literally EVERYTHING so make sure you target the right ones and make your post count. Check out our subreddit suggestions for startups and mobile apps and have a look at the Reddit rules while you’re at it:

 

3. PRODUCT HUNT

You will be hard pressed to find a more engaging platform than Product Hunt with such a passionate following and community. The world’s best and brightest product managers and tech lovers constantly stay up to date with Product Hunt to get a feel of what is going on in the tech world. Making a splash on Product Hunt would bring you a vast number of users who would be eager to use your app.

 

4. BETA DIRECTORIES

Another great way to get your idea out there is sharing it on a beta directory to attract passionate techies and early adopters. The downside is that these users are more curious than loyal and probably won’t be sticking around for too long. Since they’ve signed up to receive all kinds of beta products, they end up not being the most engaged. You’ll still end up with a bunch of beta testers and your SEO will benefit from the links these directories will provide. Here’s a list of the best beta directories you’ll find to get your beta users:

 

5. STARTUP DIRECTORIES

If you’re confident in your product and you’re ready to get even more users, I encourage you to list your startup in any of the popular startup directories that publish frequent reviews on the hottest apps and startups. Tons of early adopters and tech lovers follow and subscribe to these sites, so you’re bound to attract their attention. The best products will always get significant traction and conversions. Here’s a list of the startup directories we think will help you get the most beta users:

 

6. QUORA

Quora is one of those places with a fast-growing community that can have a very positive impact on your app’s success. The catch is that you’ll need to build up your own community by demonstrating expertise in a specific niche. Show your genuine care and passion for your domain by offering your insights on various threads within your niche. This will pay dividends and people will eventually be willing to help you in return with your own app or startup.

 

7. TWITTER

Nobody will be more willing to try out your app more than those who already hate your competitor. Hunt for them, find them, and show them. You will find that unhappy users are your friends.

 

 

Here’s a list of hashtags that could be useful to you:

 

8. HUSTLE

Let’s be real here: No app or startup grows without some true grit and hustle. Leverage social media to attract beta testers to your app. Don’t be afraid to try your own methods and see what works for you. Try Facebook groups, Twitter hashtags relevant to your product, follow relevant Twitter lists, try Pinterest, use your alma matter or high school if that could be useful. Don’t leave any stone unturned.