An electrocardiogram (ECG) is a non-invasive medical test that measures the electrical activity of the heart. Electrodes are placed on the skin to detect the heart's electrical impulses, which are then recorded and displayed as waves on a monitor or printout. This helps in diagnosing various heart conditions.