We suggest a new approach to hypothesis testing for ergodic and stationary processes. In contrast to standard methods, the suggested approach gives a possibility to make tests, based on any lossless data compression method even if the distribution law of the codeword lengths is not known. We apply this approach to the following four problems: goodness-of-fit testing (or identity testing), testing for independence, testing of serial independence and homogeneity testing and suggest nonparametric statistical tests for these problems. It is important to note that practically used so-called archivers can be used for suggested testing. AMS subject classification: 60G10, 60J10, 62M02, 62M07, 94A29. keywords universal coding, data compression, hypothesis testing, nonparametric testing, Shannon entropy, stationary and ergodic source.