In this paper we propose an analytical approach for estimating the reliability of a component-based software. This methodology assumes that the software components are heterogeneous and the transfers of control between components follow a discrete time Markov process. Besides, we also formulate and. solve two resource allocation problems. Finally, we demonstrate how these analytical approaches can be employed to measure the reliability of a software system including multiple-input/multiple-output systems and distributed software systems. Experimental results show that the proposed methods can solve the testing-effort allocation problems and improve the quality and reliability of a software system.