There are currently two classes of theories of formation of giant planets: the nucleation model and the gas instability model. The comparison of atmospheric compositions of giant planets permits a test of these. The observed enhancement in CNO compounds in all giant planets, and in deuterium in Uranus, compared with the solar abundance, is consistent with the nucleation model in which a core first grows from accretion of planetesimals and subsequently attracts the surrounding gaseous material of the nebula. However, available data do not permit us to definitively exclude the gas instability model. The agreement of the helium abundance observed in Uranus with the solar value and the depletion observed in Jupiter and Saturn is well explained by the differentiation of helium from metallic hydrogen occurring in the interiors of Jupiter and Saturn but not within Uranus where hydrogen cannot become metallic. Accurate in situ measurements of elemental and isotopic ratios made aboard atmospheric probes descending into atmospheres of giant planets are indispensable for a firm discrimination between various theories of planetary formation.