Ejemplo n.º 1
0
        /// <summary>
        /// JMeterGenerator constructor. Use to initialize the generator with all information it will need to generate the scripts
        /// </summary>
        /// <param name="outputPath">Folder where the generator will place the scripts it will create</param>
        /// <param name="dataPoolsPath"></param>
        /// <param name="performanceScript">GXTest XML info file that shows steps, validations and other commands</param>
        /// <param name="fiddlerSessions">HTTP Sessions given by fiddler</param>
        /// <param name="server">serverName:PortNumber</param>
        /// <param name="webApp">WebAppName</param>
        /// <param name="isGenexusApp">Indicates if the app is a genexus generated app. Taking some decisions for that case.</param>
        /// <param name="isBMScript">Indicates if the script is for BlazeMeter. Taking some decisions for that case.</param>
        /// <param name="isSecondary">Indicates if the script must generate sencodary requests.</param>
        /// <param name="isBeanShell">Indicates if the script must generate BeanSell Assertions.</param>
        /// <param name="replaceInBodies"></param>
        /// <param name="ext"></param>
        public ScriptGenerator(string outputPath, string dataPoolsPath, XmlDocument performanceScript, IList <Session[]> fiddlerSessions, string server, string webApp, bool isGenexusApp, bool replaceInBodies = false, IEnumerable <string> ext = null, bool isBMScript = false, bool isSecondary = true, bool isBeanShell = true)
        {
            OutputPath    = outputPath;
            DataPoolsPath = dataPoolsPath;
            IsBMScript    = isBMScript;
            IsSecondary   = isSecondary;
            IsBeanShell   = isBeanShell;
            IsGenexusApp  = isGenexusApp;

            var extenssions = ext == null? Extenssions : Extenssions.Concat(ext).ToArray();

            if (fiddlerSessions == null)
            {
                throw new Exception("Fiddler Sessions is null");
            }

            if (fiddlerSessions.Count < 1)
            {
                throw new Exception("Fiddler Sessions is empty");
            }

            if (performanceScript == null)
            {
                // todo: manage datapools of fiddler extension
                string[] datapoolsPath = { };
                performanceScript = GenerateXML(fiddlerSessions[0], "_AutogeneratedName", datapoolsPath);
            }

            ScriptWrapper   = new GxTestScriptWrapper(performanceScript);
            FiddlerSessions = new FiddlerSessionsWrapper[fiddlerSessions.Count];
            for (var i = 0; i < fiddlerSessions.Count; i++)
            {
                FiddlerSessions[i] = new FiddlerSessionsWrapper(fiddlerSessions[i]);
            }

            ServerName = server;
            WebAppName = webApp;

            ScriptName = ScriptWrapper.ScriptName;

            // compare sessions once in the constructor of the class
            if (FiddlerSessions.Length > 1)
            {
                var fiddlerComparer = new FiddlerSessionComparer.FiddlerSessionComparer(replaceInBodies, isGenexusApp);
                fiddlerComparer.Load(FiddlerSessions[0].GetSessions(), FiddlerSessions[1].GetSessions(), extenssions);
                _resultOfComparer = fiddlerComparer.CompareFull();

                for (var i = 2; i < FiddlerSessions.Length; i++)
                {
                    _resultOfComparer = fiddlerComparer.CompareFull(FiddlerSessions[i].GetSessions());
                }
            }

            //// if (debug)
            ////if (_resultOfComparer != null)
            ////{
            ////    const string fName = @"D:\Abstracta\Desarrollo\gxtest\BranchGeneradoras\Generadoras\TestCases\ASESP3\pages.txt";
            ////    (new StreamWriter(fName)).Write(_resultOfComparer.ToString("", false));
            ////}
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is an example of using the Fiddler session comparer
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            const string fiddlerSessionsFile1 = @"";
            const string fiddlerSessionsFile2 = @"";
            const string fiddlerSessionsFile3 = @"";

            const string pagesResultFile = @"pruebaAuto-Param.txt";
            const bool   isGenexusApp    = true;
            const bool   replaceInBodies = true;

            var fiddlerComparer = new FiddlerSessionComparer.FiddlerSessionComparer(replaceInBodies, isGenexusApp);

            fiddlerComparer.Load(fiddlerSessionsFile1, fiddlerSessionsFile2, null);

            var result = fiddlerComparer.CompareFull();

            // save page structure result to file
            (new StreamWriter(pagesResultFile)).WriteLine(result.ToString("", false));
        }