Since both correlation and t-test are about relationships between X and Y, what is the difference between them and when do you use t-test (or correlation)? This tutorial aims to answer these two questions.
The following figure presents the difference between t-test and correlation. In particular, t-test deals with situations where X is a binary variable, whereas correlation deal with situations where X is a continuous variable. Note that, for both t-test and correlation, the Y variable needs to be a continuous variable.
The common mistake people would when conceptually thinking of correlation and t-test is that: correlation is about the relationship between 2 variables (i.e., X and Y) whereas t-test is about the difference between 2 groups.
However, as shown above, both t-test and correlation are about the relationship between X and Y. The only difference is that X in t-test is a binary variable, whereas X in correlation is a continuous variable.
Actually, you could do a median split of a continuous X variable, and then you can do a t-test instead of correlation. Of course, there is research showing that median split is not a good idea and thus generally it is not recommended.