I'd say it's well explained on Wikipedia
https://en.wikipedia.org/wiki/Test_set
Training set = used to fit your model , you look at it, you process it, you come up with good parameters.
Test set = independent data to check the robustness of the model you came up with at the training phase.
Imagine that you're trying to work out a relationship between how much people earn per month and how tall they are. You would study 100 people, get their salaries, measure them and try to fit some model (say a linear model). With that training data you would end up with a fit of the form:
$h = \alpha e + \beta + \text{noise}$
where $h$ is a person's height, $e$ is a person's salary and $\alpha$ and $\beta$ are picked, based on your data to provide a good fit.
Now, let's say you want to evaluate how good this model is. One thing would be to look at how big "noise" is. But another thing is: does this model work on other data, on people I have not seen ??? if it does then it's a good model, I may have actually found something. If not, then you've just found something within your data which is not reproducible.
So this is why people split the data set they have in training and test usually with an 80/20 thumb rule so that they can artificially recreate the test above for robustness.
Alright.
Onwards with your next question. The prediction formula looks like it's computing the square of the error for a single test point. I don't think it's a framework per se. However people do consider things like the MSE https://en.wikipedia.org/wiki/Mean_squared_error (which is what you have here with $n=1$ or the RMSE https://en.wikipedia.org/wiki/Root-mean-square_deviation which is a direct extension and many other depending on what you're interested in but these two are fairly standard.