This work reports the first systematic study on cavitation and bubble nucleation using molecular dynamics simulation method. It successfully simulates the hysteretic process of bubble collapse and nucleation as a numerical counterpart of the Berthelot tube cavitation experiment. For a unary molecule system a stable bubble regime and minimum equimolar dividing radii of bubbles are obtained with respect to computational domain sizes. For a binary molecule system the addition of foreign molecules to the solvent molecules stimulates the nucleation more effectively in comparison to that in the unary system. The affinity between the solute and the solvent molecules controls the inception of nucleation and results in different nucleation characteristics according to its value. For an attraction coefficient greater than unity the solute molecules spread uniformly and attract the solvent molecules, which induces bubble nucleation readily. For the coefficient less than unity the solvent molecules segregate themselves from the solvent molecules, which results in a void shell between the solute and the solvent molecules.