This is sometimes done during evaluation or testing to get the exact loss in case the last batch is smaller than the rest. If you just add the test losses together, remember that in the default case each one will be an average over the current batch. If all batches have the same length, you can just divide this accumulated loss by the number of batches (len(test_loader)) and you should get the average loss for this epoch.
However, if the dataset length is not divisible by the batch size without a remainder, the last batch will be smaller than the rest. Summing all the batch averages together and just dividing by the number of batches will give you a slightly wrong answer. To correct this you can multiply each batch loss with its length (alternatively use the summation option for your criterion) and divide this accumulated loss by the number of samples (len(test_dataset)) to get the exact test loss average.