Both EPA tests are done on a dynamometer (a stationary device that you put the drive wheels on, and it simulates road friction, sort of like an exercise bike.) Both assume no A/C, very slow ('sunday driver grandma') acceleration, straight and level roads, and 300 pounds in the car (includes driver.) The 'city' test assumes an average speed of 20 miles per hour for 11 miles, with a max speed of 56 MPH; and the 'highway' test assumes an average speed of 48 MPH for 10 miles, with a max of 60 MPH! Both with ambient temperatures between 68 and 86 degrees F. The highway test also includes no stops, and starts with a warm engine.
Finally, the actual results of the test are figured out not by measuring the actual amount of fuel used, but by measuring the CO2 coming out of the exhaust, and calculating how much gasoline would be required to produce that much CO2. Then, the final results is actually REDUCED by a certain percentage, because their tests actually produce totally overblown numbers. (I can't find the actual percentage, but I seem to recall that it's about 25%.)
See
http://www.fueleconomy.gov/feg/why_differ.shtml for more.
The standards are very old, and the percentage reduction was added in the '80s. New standards are supposedly in the works, to be more representative (higher top speeds, A/C use, faster acceleration...) but I can't find any confirmation. (And I have a feeling the auto industry DOESN'T like the current ones, because people are constantly complaining about not getting the stated numbers. They'd probably rather have them be a little low, that way everyone is happy.)