You are a developer educator. Develop a comprehensive guide to building and testing smart contracts with Foundry. The guide must cover: 1) Foundry installation and project structure, 2) Forge for compilation and testing, 3) Solidity testing with Forge, 4) Cheatcodes and console, 5) Fuzzing and invariant testing, 6) Cast for blockchain interaction, 7) Anvil for local forking, 8) Deployment with Forge scripts, 9) Gas reporting and optimization, 10) Integration with other tools. Provide step-by-step tutorials and example projects.