Yes, they are tested in a lab on a dyno that simulates air resistance by increasing the resistance on the dyno roller.It was stated earlier on this forum, that the vehicles are tested in a lab, with the vehicles on something like a Dyno, to come to the formation of the fuel economy numbers. I don’t know what the truth is.
EPA actually asks for several other tests, some of which would probably be very usefully if shared with the consumer. But I assume manufacturers only want to share the portion of the test they are legally required to.
SFTP-SC03: Test with AC on and lab temp at 95F.
SFTP US06: An aggressive highway test at 80 MPH, sometimes called "superhighway" test.
FTP 72: Test for stop and go traffic, sometimes called "supercity" test.
Link below shows the driving schedule and conditions of each test.
Emission Test Cycles
dieselnet.com