Hydrotesting of pipes, pipelines and vessels is performed to expose defective materials that have missed prior detection, ensure that any remaining defects are insignificant enough to allow operation at design pressures, expose possible leaks and serve as a final validation of the integrity of the constructed system. ASME B31.3 requires this testing to ensure tightness and strength.
Buried high pressure oil and gas pipelines are tested for strength by pressurising them to at least 125% of their maximum allowable working pressure (MAWP) at any point along their length. Since many long distance transmission pipelines are designed to have a steel hoop stress of 80% of specified minimum yield strength (SMYS) at Maximum allowable operating pressure MAOP, this means that the steel is stressed to SMYS and above during the testing, and test sections must be selected to ensure that excessive plastic deformation does not occur.
For piping built to ASME B31.3, if the design temperature is greater than the test temperature, then the test pressure must be adjusted for the related allowable stress at the design temperature.  This is done by multiplying 1.5 MAWP by the ratio of the allowable stress at the test temperature to allowable stress at the design temperature per ASME B31.3 Section 345.4.2 Equation 24.  Test pressures need not exceed a value that would produce a stress higher than yield stress at test temperature. ASME B31.3 section 345.4.2 (c)
Other codes require a more onerous approach.  BS PD 8010-2 requires testing to 150% of the design pressure – which should not be less than the MAOP plus surge and other incidental effects that will occur during normal operation.
Leak testing is performed by balancing changes in the measured pressure in the test section against the theoretical pressure changes calculated from changes in the measured temperature of the test section.
Australian standard AS2885.5 "Pipelines – Gas and liquid petroleum: Part 5: Field pressure testing" gives an excellent explanation of the factors involved.
In the aerospace industry, depending on the airline, company or customer, certain codes will need to be followed. For example, Bell Helicopter has a certain specification that will have to be followed for any parts that will be used in their helicopters.