Vehicle to Everything (V2X) technology is fast evolving, and it will soon transform our driving experience. Vehicles employ On-Board Units (OBUs) to interact with various V2X devices, and these data are used for calculation and detection. Safety, efficiency, and information services are among its core uses, which are currently in the testing stage. Developers gather logs during the real field test to see if the application is fair. Field testing, on the other hand, has low efficiency, coverage, controllability, and stability, as well as the inability to recreate extreme hazardous scenarios. The shortcomings of actual road testing can be compensated for by indoor testing. An HIL-based laboratory simulation test framework for V2X-related testing is built in this study, together with the relevant test cases and a test evaluation system. The framework can test common applications such as Forward Collision Warning (FCW), Intersection Collision Warning (ICW) and others, as well as more advanced features such as Cooperative Adaptive Cruise Control (CACC) testing and Global Navigation Satellite System (GNSS) injection testing. The results of the tests reveal that the framework (CarTest) has reliable output, strong repeatability, the capacity to simulate severe danger scenarios, and is highly scalable, according to this study. Meanwhile, for the benefit of researchers, this publication highlights several relevant HIL challenges and solutions.