Compositionally graded materials have emerged at the frontier of science involving material science, engineering, physics, and chemistry due to their unusual and tunable material properties derived from spatial variations in compositions. However, achieving a comprehensive understanding of the mechanical and failure behavior of compositionally graded nanostructures, particularly at the atomic level, has remained elusive. In this study, molecular dynamics simulations are used to investigate the tensile mechanical and failure properties of CuNi nanowires with compositional gradients. The nanowires exhibit a dual variation in composition along the longitudinal direction following power-law functions. The findings demonstrate that Young's modulus, ultimate tensile strength, and yielding stress of nanowires decrease with an increase in the gradient index. Remarkably, the mechanical properties exhibit higher sensitivity to changes in the gradient index for nanowires displaying composition distribution in a convex function, while they exhibit lower sensitivity for those with concave functions. Furthermore, the necking and failure processes predominantly occur in regions with highly varied compositions. Moreover, as the gradient index increases, the distance between the necking position and the mid-plane of nanowires decreases. Additionally, this study provides a detailed discussion of the phase transitions that occur during the tension process.