Cannot add version of main.css to wordpress on testing enviroment

To answer the question why you can’t add the theme’s version to your CSS file, it’s likely because the Version property of $theme is private so you cannot access it directly, but you can access it through the public get function. Try this instead:

$theme = wp_get_theme();
define('THEME_VERSION', $theme->get('Version'));

You also don’t need to add the query to the end of your file when enqueing. Simply adding a valid version to the wp_enqueue_style() function will automatically append it.

wp_enqueue_style(
    'main',
    get_template_directory_uri().'/assets/css/main.css',
    array(),
    THEME_VERSION,
    'all'
);

However, if this still doesn’t solve your caching issue for the dev/testing environment, I’ll use this for file versioning when enqueing my assets:

function front_assets_load() {
    if (is_admin()) return;

    /* Enqueue theme script & style */
    wp_enqueue_style(
        'main',
        get_template_directory_uri().'/assets/css/main.css',
        array(),
        filemtime(get_template_directory().'/assets/css/main.css'),
        'all'
    );
}
add_action('wp_enqueue_scripts', 'front_assets_load');

The filemtime() will output a timestamp of when the file was last modified, so everytime you update the file in your testing environment, it will also update the version number and hopefully force your browser to get a non-cached version of it.