Create a Knowledge Base Article from Apex Dynamically without knowing article type API name

Here is the apex code to to achieve the same. Run in dev console then use in your test class or anywhere else you want: