In February 2023, Rathnayake was selected for Sri Lanka's Test squad for their series against New Zealand.[5] In April 2023, he was again named in Test squad for the series against Ireland.[6][7]
In August 2024, he was named in Sri Lanka's Test squad for their test tour to play three match test series against England.[8][9] He made his test debut on 21 August 2024 against England at Old Trafford and walked out to bat at number nine position for Sri Lanka on his debut and he came out to bat at a crucial time when Sri Lanka were under all sorts of trouble at 113 for the loss of 7 wickets.[10][11] On the first day of the test match on his debut, he scored a half-century and was dismissed after scoring a valiant 72 after facing 135 deliveries, as he engaged in a lower order resistance and fightback, batting way down the order to rescue Sri Lanka from a precarious position to a somewhat respectable competitive total of 236 runs on the board in the first innings.[12][13] He also eventually ended up as the second best batter for Sri Lanka besides the skipper Dhananjaya de Silva during Sri Lanka's first innings scorecard of 236 and he also broke India's Balwinder Sandhu's test record for the best individual test batting performance by a number nine batsman on test debut in an innings.[14][15][16]