Is it possible to execute a method before and after all tests in the assembly?

I would like to built an nunit project for selenium ui automation. I would like to sign in to the site before running all tests (all of them) and to close the browser after running all tests (all of them).

I can’t use the SetUp since it related to fixtures and I want to do it before and after everything.

Do you know who to execute it?

If all your test fixtures are within the same namespace then you can use the [SetUpFixture] attribute to mark a class as the global setup and teardown. You can then put all your login/logout functionality in there.

NUNIT 2.x

namespace MyNamespace.Tests
{
    using System;
    using NUnit.Framework;

    [SetUpFixture]
    public class TestsSetupClass
    {
        [SetUp]
        public void GlobalSetup()
        {
            // Do login here.
        }

        [TearDown]
        public void GlobalTeardown()
        {
            // Do logout here
        }
    }
}

See: http://www.nunit.org/index.php?p=setupFixture&r=2.4

NUNIT 3.x

namespace MyNamespace.Tests
{
    using System;
    using NUnit.Framework;

    [SetUpFixture]
    public class TestsSetupClass
    {
        [OneTimeSetUp]
        public void GlobalSetup()
        {
            // Do login here.
        }

        [OneTimeTearDown]
        public void GlobalTeardown()
        {
            // Do logout here
        }
    }
}

See: https://github.com/nunit/docs/wiki/SetUpFixture-Attribute