The vessel is filled with a nearly incompressible liquid - usually water or oil - and examined for leaks or permanent changes in shape. The test pressure is always considerably more than the operating pressure to give a margin for safety, typically 150% of the operating pressure. Water is commonly used because it is almost incompressible, so will only expand by a very small amount should the vessel split.
If high pressure gas was used, then the gas would expand to perhaps several hundred times its compressed volume in an explosion, with the attendant risk of damage or injury. This is the risk which the testing is intended to mitigate.
Small pressure vessels are normally tested using a water jacket test. The vessel is visually examined for defects and then placed in a container filled with water, and in which the change in volume of the vessel can be measured by monitoring the water level. The vessel is then pressurised for a specified period and depressurised again. The water level in the jacket is then examined. The level will be greater if the vessel being tested has been distorted by the pressure change and did not return to its original volume or some of the pressurised water inside has leaked out. In both cases, this will normally signify that the vessel has failed the test.
A simpler test is to pressurise the vessel with water and physically examine the outside for leaks. Red or fluorescent dyes are usually added to the water to make leaks easier to see.
Most countries have legislation that requires pressure vessels to be regularly tested, for example every two years (with a visual inspection annually) for high pressure gas cylinders and every five or ten years for lower pressure ones such as used in fire extinguishers. Gas cylinders which fail are normally destroyed as part of the testing protocol to avoid the dangers inherent in them being subsequently used.