I provided a page from the tech sheet for a common Kenmore HE4 dryer that describes the diagnostic test functions. Without a model number, I cannot be certain that this technical information will work for your dryer, but I suspect that it will. Entering the diagnostic test mode will allow you to check several component inputs to the control board. Based on your description, I recommend checking the door switch. You could also have a problem with the control console or the electronic control board. Pressing the PAUSE/CANCEL key will exit this diagnostic test mode.
If you need more help, resubmit your question with additional details and the full model number of your HE4 dryer.